Skip to content

Commit

Permalink
change return type of merge functions to CompletionStage;
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Maute <stefan.maute@bosch.io>
  • Loading branch information
Stefan Maute committed Feb 9, 2021
1 parent 05c2bd7 commit a90f4f7
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 45 deletions.
Expand Up @@ -383,7 +383,7 @@ private CompletionStage<Thing> processCreate(final Thing thing, @Nullable final


@Override
public CompletableFuture<Void> merge(final ThingId thingId, final JsonObject jsonObject,
public CompletionStage<Void> merge(final ThingId thingId, final JsonObject jsonObject,
final Option<?>... options) {
argumentNotNull(jsonObject);

Expand All @@ -392,7 +392,7 @@ public CompletableFuture<Void> merge(final ThingId thingId, final JsonObject jso
}

@Override
public CompletableFuture<Void> merge(final ThingId thingId, final Thing thing,
public CompletionStage<Void> merge(final ThingId thingId, final Thing thing,
final Option<?>... options) {
argumentNotNull(thing);

Expand Down
Expand Up @@ -313,7 +313,7 @@ public interface CommonManagement<T extends ThingHandle, F extends FeatureHandle
* @throws IllegalArgumentException if {@code argument} is {@code null}.
* @since 2.0.0
*/
CompletableFuture<Void> merge(ThingId thingId, Thing thing, Option<?>... options);
CompletionStage<Void> merge(ThingId thingId, Thing thing, Option<?>... options);

/**
* Merges a {@link Thing} if it does exist based on the given {@link JsonObject}.
Expand All @@ -327,7 +327,7 @@ public interface CommonManagement<T extends ThingHandle, F extends FeatureHandle
* @throws IllegalArgumentException if {@code argument} is {@code null}.
* @since 2.0.0
*/
CompletableFuture<Void> merge(ThingId thingId, JsonObject thing, Option<?>... options);
CompletionStage<Void> merge(ThingId thingId, JsonObject thing, Option<?>... options);

/**
* Puts the given {@link Thing}, which means that the Thing might be created or updated. The behaviour can be
Expand Down
Expand Up @@ -49,12 +49,12 @@ public interface FeatureDefinitionManagement {
* @param definition the FeatureDefinition to be merged.
* @param options options to be applied configuring behaviour of this method, see {@link
* org.eclipse.ditto.client.options.Options}.
* @return a CompletableFuture providing the result of this operation or a specific {@link
* @return a CompletionStage providing the result of this operation or a specific {@link
* org.eclipse.ditto.model.base.exceptions.DittoRuntimeException} if the operation failed.
* @throws NullPointerException if any argument is {@code null}.
* @since 2.0.0
*/
CompletableFuture<Void> mergeDefinition(FeatureDefinition definition, Option<?>... options);
CompletionStage<Void> mergeDefinition(FeatureDefinition definition, Option<?>... options);

/**
* Deletes the definition of the Feature.
Expand Down
Expand Up @@ -230,7 +230,7 @@ default CompletionStage<Void> putProperty(final CharSequence path, final JsonVal
* @throws IllegalArgumentException if {@code path} is {@code null} or empty.
* @since 2.0.0
*/
default CompletableFuture<Void> mergeProperty(final CharSequence path, final boolean value,
default CompletionStage<Void> mergeProperty(final CharSequence path, final boolean value,
final Option<?>... options) {
argumentNotNull(path);
return mergeProperty(JsonFactory.newPointer(path), JsonFactory.newValue(value), options);
Expand All @@ -249,7 +249,7 @@ default CompletableFuture<Void> mergeProperty(final CharSequence path, final boo
* @throws IllegalArgumentException if {@code path} is {@code null} or empty.
* @since 2.0.0
*/
default CompletableFuture<Void> mergeProperty(final CharSequence path, final double value,
default CompletionStage<Void> mergeProperty(final CharSequence path, final double value,
final Option<?>... options) {
argumentNotNull(path);
return mergeProperty(JsonFactory.newPointer(path), JsonFactory.newValue(value), options);
Expand All @@ -269,7 +269,7 @@ default CompletableFuture<Void> mergeProperty(final CharSequence path, final dou
* @throws IllegalArgumentException if {@code path} is {@code null} or empty.
* @since 2.0.0
*/
default CompletableFuture<Void> mergeProperty(final CharSequence path, final int value,
default CompletionStage<Void> mergeProperty(final CharSequence path, final int value,
final Option<?>... options) {
argumentNotNull(path);
return mergeProperty(JsonFactory.newPointer(path), JsonFactory.newValue(value), options);
Expand All @@ -289,7 +289,7 @@ default CompletableFuture<Void> mergeProperty(final CharSequence path, final int
* @throws IllegalArgumentException if {@code path} is {@code null} or empty.
* @since 2.0.0
*/
default CompletableFuture<Void> mergeProperty(final CharSequence path, final long value,
default CompletionStage<Void> mergeProperty(final CharSequence path, final long value,
final Option<?>... options) {
argumentNotNull(path);
return mergeProperty(JsonFactory.newPointer(path), JsonFactory.newValue(value), options);
Expand All @@ -309,7 +309,7 @@ default CompletableFuture<Void> mergeProperty(final CharSequence path, final lon
* @throws IllegalArgumentException if {@code path} is {@code null} or empty.
* @since 2.0.0
*/
default CompletableFuture<Void> mergeProperty(final CharSequence path, final String value,
default CompletionStage<Void> mergeProperty(final CharSequence path, final String value,
final Option<?>... options) {
argumentNotNull(path);
return mergeProperty(JsonFactory.newPointer(path), JsonFactory.newValue(value), options);
Expand All @@ -328,7 +328,7 @@ default CompletableFuture<Void> mergeProperty(final CharSequence path, final Str
* @throws IllegalArgumentException if {@code path} is {@code null} or empty.
* @since 2.0.0
*/
default CompletableFuture<Void> mergeProperty(final CharSequence path, final JsonValue value,
default CompletionStage<Void> mergeProperty(final CharSequence path, final JsonValue value,
final Option<?>... options) {
argumentNotNull(path);
return mergeProperty(JsonFactory.newPointer(path), value, options);
Expand All @@ -346,7 +346,7 @@ default CompletableFuture<Void> mergeProperty(final CharSequence path, final Jso
* @throws IllegalArgumentException if {@code path} is {@code null} or empty.
* @since 2.0.0
*/
CompletableFuture<Void> mergeProperty(JsonPointer path, JsonValue value, Option<?>... options);
CompletionStage<Void> mergeProperty(JsonPointer path, JsonValue value, Option<?>... options);

/**
* Sets the given properties of the Feature.
Expand All @@ -369,7 +369,7 @@ default CompletableFuture<Void> mergeProperty(final CharSequence path, final Jso
* org.eclipse.ditto.model.base.exceptions.DittoRuntimeException} if the operation failed
* @since 2.0.0
*/
CompletableFuture<Void> mergeProperties(JsonObject value, Option<?>... options);
CompletionStage<Void> mergeProperties(JsonObject value, Option<?>... options);

/**
* Deletes the property specified by the given path.
Expand Down
Expand Up @@ -233,7 +233,7 @@ default CompletionStage<Void> putAttribute(final CharSequence path, final JsonVa
* @throws IllegalArgumentException if {@code path} is {@code null} or empty.
* @since 2.0.0
*/
default CompletableFuture<Void> mergeAttribute(final CharSequence path, final boolean value,
default CompletionStage<Void> mergeAttribute(final CharSequence path, final boolean value,
final Option<?>... options) {
argumentNotNull(path);
return mergeAttribute(JsonFactory.newPointer(path), JsonFactory.newValue(value), options);
Expand All @@ -252,7 +252,7 @@ default CompletableFuture<Void> mergeAttribute(final CharSequence path, final bo
* @throws IllegalArgumentException if {@code path} is {@code null} or empty.
* @since 2.0.0
*/
default CompletableFuture<Void> mergeAttribute(final CharSequence path, final double value,
default CompletionStage<Void> mergeAttribute(final CharSequence path, final double value,
final Option<?>... options) {
argumentNotNull(path);
return mergeAttribute(JsonFactory.newPointer(path), JsonFactory.newValue(value), options);
Expand All @@ -271,7 +271,7 @@ default CompletableFuture<Void> mergeAttribute(final CharSequence path, final do
* @throws IllegalArgumentException if {@code path} is {@code null} or empty.
* @since 2.0.0
*/
default CompletableFuture<Void> mergeAttribute(final CharSequence path, final int value,
default CompletionStage<Void> mergeAttribute(final CharSequence path, final int value,
final Option<?>... options) {
argumentNotNull(path);
return mergeAttribute(JsonFactory.newPointer(path), JsonFactory.newValue(value), options);
Expand All @@ -290,7 +290,7 @@ default CompletableFuture<Void> mergeAttribute(final CharSequence path, final in
* @throws IllegalArgumentException if {@code path} is {@code null} or empty.
* @since 2.0.0
*/
default CompletableFuture<Void> mergeAttribute(final CharSequence path, final long value,
default CompletionStage<Void> mergeAttribute(final CharSequence path, final long value,
final Option<?>... options) {
argumentNotNull(path);
return mergeAttribute(JsonFactory.newPointer(path), JsonFactory.newValue(value), options);
Expand All @@ -309,7 +309,7 @@ default CompletableFuture<Void> mergeAttribute(final CharSequence path, final lo
* @throws IllegalArgumentException if {@code path} is {@code null} or empty.
* @since 2.0.0
*/
default CompletableFuture<Void> mergeAttribute(final CharSequence path, final String value,
default CompletionStage<Void> mergeAttribute(final CharSequence path, final String value,
final Option<?>... options) {
argumentNotNull(path);
return mergeAttribute(JsonFactory.newPointer(path), JsonFactory.newValue(value), options);
Expand All @@ -328,7 +328,7 @@ default CompletableFuture<Void> mergeAttribute(final CharSequence path, final St
* @throws IllegalArgumentException if {@code path} is {@code null} or empty.
* @since 2.0.0
*/
default CompletableFuture<Void> mergeAttribute(final CharSequence path, final JsonValue value,
default CompletionStage<Void> mergeAttribute(final CharSequence path, final JsonValue value,
final Option<?>... options) {
argumentNotNull(path);
return mergeAttribute(JsonFactory.newPointer(path), value, options);
Expand All @@ -346,7 +346,7 @@ default CompletableFuture<Void> mergeAttribute(final CharSequence path, final Js
* @throws IllegalArgumentException if any argument is {@code null} or if {@code path} is empty.
* @since 2.0.0
*/
CompletableFuture<Void> mergeAttribute(JsonPointer path, JsonValue value, Option<?>... options);
CompletionStage<Void> mergeAttribute(JsonPointer path, JsonValue value, Option<?>... options);

/**
* Sets the given attributes to this Thing.
Expand All @@ -371,7 +371,7 @@ default CompletableFuture<Void> mergeAttribute(final CharSequence path, final Js
* @throws IllegalArgumentException if {@code value} is {@code null}
* @since 2.0.0
*/
CompletableFuture<Void> mergeAttributes(JsonObject value, Option<?>... options);
CompletionStage<Void> mergeAttributes(JsonObject value, Option<?>... options);

/**
* Deletes the attribute specified by the given path.
Expand Down
Expand Up @@ -115,12 +115,12 @@ public interface ThingHandle<F extends FeatureHandle> extends WithThingId, Thing
* @param policyId the PolicyId of the Policy to be merge.
* @param options options to be applied configuring behaviour of this method, see {@link
* org.eclipse.ditto.client.options.Options}.
* @return completable future for handling the result of the operation or a specific {@link
* @return CompletionStage for handling the result of the operation or a specific {@link
* org.eclipse.ditto.model.base.exceptions.DittoRuntimeException} if the operation failed
* @throws IllegalArgumentException if {@code policyId} is {@code null}.
* @since 2.0.0
*/
CompletableFuture<Void> mergePolicyId(PolicyId policyId, Option<?>... options);
CompletionStage<Void> mergePolicyId(PolicyId policyId, Option<?>... options);

/**
* Sets the given {@code Features} to this Thing. All existing Features are replaced.
Expand All @@ -140,12 +140,12 @@ public interface ThingHandle<F extends FeatureHandle> extends WithThingId, Thing
* @param features the Features to be merged.
* @param options options to be applied configuring behaviour of this method, see {@link
* org.eclipse.ditto.client.options.Options}.
* @return completable future for handling the result of the operation or a specific {@link
* @return CompletionStage for handling the result of the operation or a specific {@link
* org.eclipse.ditto.model.base.exceptions.DittoRuntimeException} if the operation failed
* @throws IllegalArgumentException if {@code features} is {@code null}.
* @since 2.0.0
*/
CompletableFuture<Void> mergeFeatures(Features features, Option<?>... options);
CompletionStage<Void> mergeFeatures(Features features, Option<?>... options);

/**
* Updates the given Feature of this Thing or creates a new one if it does not yet exist.
Expand All @@ -165,12 +165,12 @@ public interface ThingHandle<F extends FeatureHandle> extends WithThingId, Thing
* @param feature Feature to be merged.
* @param options options to be applied configuring behaviour of this method, see {@link
* org.eclipse.ditto.client.options.Options}.
* @return completable future for handling the result of this operation or a specific {@link
* @return CompletionStage for handling the result of this operation or a specific {@link
* org.eclipse.ditto.model.base.exceptions.DittoRuntimeException} if the operation failed
* @throws IllegalArgumentException if {@code feature} is {@code null}.
* @since 2.0.0
*/
CompletableFuture<Void> mergeFeature(Feature feature, Option<?>... options);
CompletionStage<Void> mergeFeature(Feature feature, Option<?>... options);

/**
* Deletes the Feature by the given identifier from this Thing.
Expand Down
Expand Up @@ -147,11 +147,11 @@ public CompletionStage<Void> setDefinition(final FeatureDefinition featureDefini
}

@Override
public CompletableFuture<Void> mergeDefinition(final FeatureDefinition featureDefinition,
public CompletionStage<Void> mergeDefinition(final FeatureDefinition featureDefinition,
final Option<?>... options) {
final MergeThing command =
outgoingMessageFactory.mergeFeatureDefinition(thingId, featureId, featureDefinition, options);
return askThingCommand(command, CommandResponse.class, this::toVoid).toCompletableFuture();
return askThingCommand(command, CommandResponse.class, this::toVoid);
}

@Override
Expand Down Expand Up @@ -202,7 +202,7 @@ public CompletionStage<Void> putProperty(final JsonPointer path, final JsonValue
}

@Override
public CompletableFuture<Void> mergeProperty(final JsonPointer path, final JsonValue value,
public CompletionStage<Void> mergeProperty(final JsonPointer path, final JsonValue value,
final Option<?>... options) {

argumentNotNull(path, "Path");
Expand All @@ -211,7 +211,7 @@ public CompletableFuture<Void> mergeProperty(final JsonPointer path, final JsonV

final MergeThing command =
outgoingMessageFactory.mergeFeatureProperty(thingId, featureId, path, value, options);
return askThingCommand(command, CommandResponse.class, this::toVoid).toCompletableFuture();
return askThingCommand(command, CommandResponse.class, this::toVoid);
}

@Override
Expand All @@ -222,9 +222,9 @@ public CompletionStage<Void> setProperties(final JsonObject value, final Option<
}

@Override
public CompletableFuture<Void> mergeProperties(final JsonObject value, final Option<?>... options) {
public CompletionStage<Void> mergeProperties(final JsonObject value, final Option<?>... options) {
final MergeThing command = outgoingMessageFactory.mergeFeatureProperties(thingId, featureId, value, options);
return askThingCommand(command, CommandResponse.class, this::toVoid).toCompletableFuture();
return askThingCommand(command, CommandResponse.class, this::toVoid);
}

@Override
Expand Down
Expand Up @@ -182,7 +182,7 @@ public CompletionStage<Void> putAttribute(final JsonPointer path, final JsonValu
}

@Override
public CompletableFuture<Void> mergeAttribute(final JsonPointer path, final JsonValue value,
public CompletionStage<Void> mergeAttribute(final JsonPointer path, final JsonValue value,
final Option<?>... options) {
argumentNotNull(path);
argumentNotNull(value);
Expand All @@ -191,7 +191,7 @@ public CompletableFuture<Void> mergeAttribute(final JsonPointer path, final Json
"method.");

final MergeThing command = outgoingMessageFactory.mergeAttribute(thingId, path, value, options);
return askThingCommand(command, CommandResponse.class, this::toVoid).toCompletableFuture();
return askThingCommand(command, CommandResponse.class, this::toVoid);
}

@Override
Expand All @@ -205,13 +205,13 @@ public CompletionStage<Void> setAttributes(final JsonObject attributes, final Op
}

@Override
public CompletableFuture<Void> mergeAttributes(final JsonObject attributes, final Option<?>... options) {
public CompletionStage<Void> mergeAttributes(final JsonObject attributes, final Option<?>... options) {
argumentNotNull(attributes);
checkArgument(attributes, v -> v.isObject() || v.isNull(),
() -> "The root attributes entry can only be a JSON" + " object or JSON NULL literal!");

final MergeThing command = outgoingMessageFactory.mergeAttributes(thingId, attributes, options);
return askThingCommand(command, CommandResponse.class, this::toVoid).toCompletableFuture();
return askThingCommand(command, CommandResponse.class, this::toVoid);
}

@Override
Expand All @@ -223,11 +223,11 @@ public CompletionStage<Void> setFeatures(final Features features, final Option<?
}

@Override
public CompletableFuture<Void> mergeFeatures(final Features features, final Option<?>... options) {
public CompletionStage<Void> mergeFeatures(final Features features, final Option<?>... options) {
argumentNotNull(features);

final MergeThing command = outgoingMessageFactory.mergeFeatures(thingId, features, options);
return askThingCommand(command, CommandResponse.class, this::toVoid).toCompletableFuture();
return askThingCommand(command, CommandResponse.class, this::toVoid);
}

@Override
Expand All @@ -239,11 +239,11 @@ public CompletionStage<Void> setPolicyId(final PolicyId policyId, final Option<?
}

@Override
public CompletableFuture<Void> mergePolicyId(final PolicyId policyId, final Option<?>... options) {
public CompletionStage<Void> mergePolicyId(final PolicyId policyId, final Option<?>... options) {
argumentNotNull(policyId);

final MergeThing command = outgoingMessageFactory.mergePolicyId(thingId, policyId, options);
return askThingCommand(command, CommandResponse.class, this::toVoid).toCompletableFuture();
return askThingCommand(command, CommandResponse.class, this::toVoid);
}

@Override
Expand All @@ -255,11 +255,11 @@ public CompletionStage<Void> putFeature(final Feature feature, final Option<?>..
}

@Override
public CompletableFuture<Void> mergeFeature(final Feature feature, final Option<?>... options) {
public CompletionStage<Void> mergeFeature(final Feature feature, final Option<?>... options) {
argumentNotNull(feature);

final MergeThing command = outgoingMessageFactory.mergeFeature(thingId, feature, options);
return askThingCommand(command, CommandResponse.class, this::toVoid).toCompletableFuture();
return askThingCommand(command, CommandResponse.class, this::toVoid);
}

@Override
Expand Down

0 comments on commit a90f4f7

Please sign in to comment.