Class MergeThing
java.lang.Object
org.eclipse.ditto.base.model.signals.commands.AbstractCommand<MergeThing>
org.eclipse.ditto.things.model.signals.commands.modify.MergeThing
- All Implemented Interfaces:
org.eclipse.ditto.base.model.entity.id.WithEntityId,org.eclipse.ditto.base.model.entity.type.WithEntityType,org.eclipse.ditto.base.model.headers.DittoHeadersSettable<MergeThing>,org.eclipse.ditto.base.model.headers.WithDittoHeaders,org.eclipse.ditto.base.model.headers.WithManifest,org.eclipse.ditto.base.model.json.Jsonifiable<org.eclipse.ditto.json.JsonObject>,org.eclipse.ditto.base.model.json.Jsonifiable.WithPredicate<org.eclipse.ditto.json.JsonObject,,org.eclipse.ditto.json.JsonField> org.eclipse.ditto.base.model.signals.commands.Command<MergeThing>,org.eclipse.ditto.base.model.signals.Signal<MergeThing>,org.eclipse.ditto.base.model.signals.SignalWithEntityId<MergeThing>,org.eclipse.ditto.base.model.signals.WithName,org.eclipse.ditto.base.model.signals.WithOptionalEntity<MergeThing>,org.eclipse.ditto.base.model.signals.WithResource,org.eclipse.ditto.base.model.signals.WithType,ThingModifyCommand<MergeThing>,ThingCommand<MergeThing>,WithThingId
@Immutable
public final class MergeThing
extends org.eclipse.ditto.base.model.signals.commands.AbstractCommand<MergeThing>
implements ThingModifyCommand<MergeThing>
/**
This command merges an existing Thing with the supplied modification. The command contains a
path and a
value describing the change that should be applied. The value at the given path is merged
with the existing thing according to RFC7396 - JSON Merge Patch.- Since:
- 2.0.0
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.eclipse.ditto.base.model.signals.commands.Command
org.eclipse.ditto.base.model.signals.commands.Command.CategoryNested classes/interfaces inherited from interface org.eclipse.ditto.base.model.json.Jsonifiable
org.eclipse.ditto.base.model.json.Jsonifiable.WithFieldSelector, org.eclipse.ditto.base.model.json.Jsonifiable.WithFieldSelectorAndPredicate<T extends Object>, org.eclipse.ditto.base.model.json.Jsonifiable.WithPointer<J extends org.eclipse.ditto.json.JsonValue>, org.eclipse.ditto.base.model.json.Jsonifiable.WithPredicate<J extends org.eclipse.ditto.json.JsonValue,T extends Object> -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final org.eclipse.ditto.json.JsonFieldDefinition<String>Json Field definition for the optional feature to copy an existing policy.static final org.eclipse.ditto.json.JsonFieldDefinition<org.eclipse.ditto.json.JsonObject>Json Field definition for the optional initial "inline" policy for usage in getEntity().static final StringName of the "Merge Thing" command.static final StringType of this command.Fields inherited from interface org.eclipse.ditto.base.model.signals.commands.Command
TYPE_QUALIFIERFields inherited from interface org.eclipse.ditto.base.model.signals.Signal
CHANNEL_LIVE, CHANNEL_TWINFields inherited from interface org.eclipse.ditto.things.model.signals.commands.ThingCommand
RESOURCE_TYPE, TYPE_PREFIXFields inherited from interface org.eclipse.ditto.base.model.signals.WithType
MESSAGES_COMMAND_RESPONSES_PREFIX, MESSAGES_COMMANDS_PREFIX, POLICY_ANNOUNCEMENT_PREFIX, THINGS_COMMAND_RESPONSES_PREFIX, THINGS_COMMANDS_PREFIX, THINGS_EVENTS_PREFIX -
Method Summary
Modifier and TypeMethodDescriptionprotected voidappendPayload(org.eclipse.ditto.json.JsonObjectBuilder jsonObjectBuilder, org.eclipse.ditto.base.model.json.JsonSchemaVersion schemaVersion, Predicate<org.eclipse.ditto.json.JsonField> predicateParameter) protected booleanbooleanChecks whether this command may change authorization of the Thing.booleanstatic MergeThingfromJson(org.eclipse.ditto.json.JsonObject jsonObject, org.eclipse.ditto.base.model.headers.DittoHeaders dittoHeaders) Creates a newMergeThingfrom a JSON object.org.eclipse.ditto.base.model.signals.commands.Command.CategoryOptional<org.eclipse.ditto.json.JsonValue>Optional<org.eclipse.ditto.json.JsonValue>getEntity(org.eclipse.ditto.base.model.json.JsonSchemaVersion schemaVersion) Optional<org.eclipse.ditto.json.JsonObject>org.eclipse.ditto.json.JsonPointergetPath()org.eclipse.ditto.json.JsonPointerorg.eclipse.ditto.base.model.json.JsonSchemaVersion[]org.eclipse.ditto.json.JsonValuegetValue()inthashCode()static Optional<org.eclipse.ditto.json.JsonObject>initialPolicyForMergeThingFrom(org.eclipse.ditto.json.JsonObject jsonObject) Retrieves a potentially included "inline policy" from the_policyfield of the passedjsonObject.static MergeThingof(ThingId thingId, org.eclipse.ditto.json.JsonPointer path, org.eclipse.ditto.json.JsonValue value, org.eclipse.ditto.base.model.headers.DittoHeaders dittoHeaders) Creates a command for merging the thing identified bythingIdwith the givenpathandvalue.policyIdOrPlaceholderForMergeThingFrom(org.eclipse.ditto.json.JsonObject jsonObject) Retrieves a potentially included "policy id or placeholder" to copy a policy from the_copyPolicyFromfield of the passedjsonObject.setDittoHeaders(org.eclipse.ditto.base.model.headers.DittoHeaders dittoHeaders) setEntity(org.eclipse.ditto.json.JsonValue entity) toString()static MergeThingwithAttribute(ThingId thingId, org.eclipse.ditto.json.JsonPointer attributePath, org.eclipse.ditto.json.JsonValue attributeValue, org.eclipse.ditto.base.model.headers.DittoHeaders dittoHeaders) Creates a command for merging the thing identified bythingIdwith the givenattributePathandattributeValue.static MergeThingwithAttributes(ThingId thingId, Attributes attributes, org.eclipse.ditto.base.model.headers.DittoHeaders dittoHeaders) Creates a command for merging the thing identified bythingIdwith the givenattributes.static MergeThingwithFeature(ThingId thingId, Feature feature, org.eclipse.ditto.base.model.headers.DittoHeaders dittoHeaders) Creates a command for merging the thing identified bythingIdwith the givenfeature.static MergeThingwithFeatureDefinition(ThingId thingId, String featureId, FeatureDefinition featureDefinition, org.eclipse.ditto.base.model.headers.DittoHeaders dittoHeaders) Creates a command for merging the feature identified bythingIdandfeatureIdwith the givenfeatureDefinition.static MergeThingwithFeatureDesiredProperties(ThingId thingId, String featureId, FeatureProperties desiredFeatureProperties, org.eclipse.ditto.base.model.headers.DittoHeaders dittoHeaders) Creates a command for merging the feature identified bythingIdandfeatureIdwith the givendesiredFeatureProperties.static MergeThingwithFeatureDesiredProperty(ThingId thingId, String featureId, org.eclipse.ditto.json.JsonPointer propertyPath, org.eclipse.ditto.json.JsonValue propertyValue, org.eclipse.ditto.base.model.headers.DittoHeaders dittoHeaders) Creates a command for merging the feature identified bythingIdandfeatureIdwith the givenpropertyPathandpropertyValue.static MergeThingwithFeatureProperties(ThingId thingId, String featureId, FeatureProperties featureProperties, org.eclipse.ditto.base.model.headers.DittoHeaders dittoHeaders) Creates a command for merging the feature identified bythingIdandfeatureIdwith the givenfeatureProperties.static MergeThingwithFeatureProperty(ThingId thingId, String featureId, org.eclipse.ditto.json.JsonPointer propertyPath, org.eclipse.ditto.json.JsonValue propertyValue, org.eclipse.ditto.base.model.headers.DittoHeaders dittoHeaders) Creates a command for merging the feature identified bythingIdandfeatureIdwith the givenpropertyPathandpropertyValue.static MergeThingwithFeatures(ThingId thingId, Features features, org.eclipse.ditto.base.model.headers.DittoHeaders dittoHeaders) Creates a command for merging the thing identified bythingIdwith the givenfeatures.static MergeThingwithPolicyId(ThingId thingId, org.eclipse.ditto.policies.model.PolicyId policyId, org.eclipse.ditto.base.model.headers.DittoHeaders dittoHeaders) Creates a command for merging the thing identified bythingIdwith the givenpolicyId.static MergeThingwithThing(ThingId thingId, Thing thing, org.eclipse.ditto.base.model.headers.DittoHeaders dittoHeaders) Creates a command for merging the thing identified bythingIdwith the giventhing.static MergeThingwithThing(ThingId thingId, Thing thing, org.eclipse.ditto.json.JsonObject initialPolicy, String policyIdOrPlaceholder, org.eclipse.ditto.base.model.headers.DittoHeaders dittoHeaders) Creates a command for merging the thing identified bythingIdwith the giventhing.static MergeThingwithThingDefinition(ThingId thingId, ThingDefinition thingDefinition, org.eclipse.ditto.base.model.headers.DittoHeaders dittoHeaders) Creates a command for merging the thing identified bythingIdwith the giventhingDefinition.Methods inherited from class org.eclipse.ditto.base.model.signals.commands.AbstractCommand
getDittoHeaders, getManifest, getType, toJsonMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.eclipse.ditto.base.model.signals.commands.Command
getImplementedSchemaVersion, toJson, toJsonMethods inherited from interface org.eclipse.ditto.base.model.json.Jsonifiable
getLatestSchemaVersion, implementsSchemaVersion, implementsSchemaVersion, toJsonStringMethods inherited from interface org.eclipse.ditto.base.model.json.Jsonifiable.WithPredicate
toJson, toJsonString, toJsonStringMethods inherited from interface org.eclipse.ditto.base.model.signals.Signal
getNameMethods inherited from interface org.eclipse.ditto.things.model.signals.commands.ThingCommand
getEntityType, getResourceType, getTypePrefixMethods inherited from interface org.eclipse.ditto.base.model.headers.WithDittoHeaders
getDittoHeadersMethods inherited from interface org.eclipse.ditto.base.model.headers.WithManifest
getManifestMethods inherited from interface org.eclipse.ditto.base.model.signals.WithType
getType
-
Field Details
-
NAME
Name of the "Merge Thing" command.- See Also:
-
TYPE
Type of this command.- See Also:
-
JSON_INLINE_POLICY
public static final org.eclipse.ditto.json.JsonFieldDefinition<org.eclipse.ditto.json.JsonObject> JSON_INLINE_POLICYJson Field definition for the optional initial "inline" policy for usage in getEntity(). -
JSON_COPY_POLICY_FROM
Json Field definition for the optional feature to copy an existing policy.
-
-
Method Details
-
of
public static MergeThing of(ThingId thingId, org.eclipse.ditto.json.JsonPointer path, org.eclipse.ditto.json.JsonValue value, org.eclipse.ditto.base.model.headers.DittoHeaders dittoHeaders) Creates a command for merging the thing identified bythingIdwith the givenpathandvalue.- Parameters:
thingId- the thing id.path- the path that is merged with the existing thing.value- the value describing the changes that are merged with the existing thing.dittoHeaders- the ditto headers.- Returns:
- the created
MergeThingcommand.
-
withThing
public static MergeThing withThing(ThingId thingId, Thing thing, org.eclipse.ditto.base.model.headers.DittoHeaders dittoHeaders) Creates a command for merging the thing identified bythingIdwith the giventhing.- Parameters:
thingId- the thing id.thing- the thing that is merged with the existing thing.dittoHeaders- the ditto headers.- Returns:
- the created
MergeThingcommand.
-
withThing
public static MergeThing withThing(ThingId thingId, Thing thing, @Nullable org.eclipse.ditto.json.JsonObject initialPolicy, @Nullable String policyIdOrPlaceholder, org.eclipse.ditto.base.model.headers.DittoHeaders dittoHeaders) Creates a command for merging the thing identified bythingIdwith the giventhing. Only one of the arguments initialPolicy and policyIdOrPlaceholder must not be null. They are both allowed to be null, but not both to not be null at the same time.- Parameters:
thingId- the thing id.thing- the thing that is merged with the existing thing.policyIdOrPlaceholder- the policy id of thePolicyto copy and set for the Thing when creating it. If it's a placeholder it will be resolved to a policy id. Placeholder must be of the syntax:{{ ref:things/<theThingId>/policyId }}.initialPolicy- the initialPolicyto set for the Thing when creating it - may be null.dittoHeaders- the ditto headers.- Returns:
- the created
MergeThingcommand. - Since:
- 3.3.0
-
withPolicyId
public static MergeThing withPolicyId(ThingId thingId, org.eclipse.ditto.policies.model.PolicyId policyId, org.eclipse.ditto.base.model.headers.DittoHeaders dittoHeaders) Creates a command for merging the thing identified bythingIdwith the givenpolicyId.- Parameters:
thingId- the thing id.policyId- the policyId that is merged with the existing thing.dittoHeaders- the ditto headers.- Returns:
- the created
MergeThingcommand.
-
withThingDefinition
public static MergeThing withThingDefinition(ThingId thingId, ThingDefinition thingDefinition, org.eclipse.ditto.base.model.headers.DittoHeaders dittoHeaders) Creates a command for merging the thing identified bythingIdwith the giventhingDefinition.- Parameters:
thingId- the thing id.thingDefinition- the thing definition that is merged with the existing thing.dittoHeaders- the ditto headers.- Returns:
- the created
MergeThingcommand.
-
withAttributes
public static MergeThing withAttributes(ThingId thingId, Attributes attributes, org.eclipse.ditto.base.model.headers.DittoHeaders dittoHeaders) Creates a command for merging the thing identified bythingIdwith the givenattributes.- Parameters:
thingId- the thing id.attributes- the attributes that are merged with the existing thing.dittoHeaders- the ditto headers.- Returns:
- the created
MergeThingcommand.
-
withAttribute
public static MergeThing withAttribute(ThingId thingId, org.eclipse.ditto.json.JsonPointer attributePath, org.eclipse.ditto.json.JsonValue attributeValue, org.eclipse.ditto.base.model.headers.DittoHeaders dittoHeaders) Creates a command for merging the thing identified bythingIdwith the givenattributePathandattributeValue.- Parameters:
thingId- the thing id.attributePath- the path where the attribute value is merged with the existing thing.attributeValue- the attribute value that is merged with the existing thing.dittoHeaders- the ditto headers.- Returns:
- the created
MergeThingcommand.
-
withFeatures
public static MergeThing withFeatures(ThingId thingId, Features features, org.eclipse.ditto.base.model.headers.DittoHeaders dittoHeaders) Creates a command for merging the thing identified bythingIdwith the givenfeatures.- Parameters:
thingId- the thing id.features- the features that are merged with the existing thing.dittoHeaders- the ditto headers.- Returns:
- the created
MergeThingcommand.
-
withFeature
public static MergeThing withFeature(ThingId thingId, Feature feature, org.eclipse.ditto.base.model.headers.DittoHeaders dittoHeaders) Creates a command for merging the thing identified bythingIdwith the givenfeature.- Parameters:
thingId- the thing id.feature- the feature that is merged with the existing thing.dittoHeaders- the ditto headers.- Returns:
- the created
MergeThingcommand.
-
withFeatureDefinition
public static MergeThing withFeatureDefinition(ThingId thingId, String featureId, FeatureDefinition featureDefinition, org.eclipse.ditto.base.model.headers.DittoHeaders dittoHeaders) Creates a command for merging the feature identified bythingIdandfeatureIdwith the givenfeatureDefinition.- Parameters:
thingId- the thing id.featureId- the feature id identifying the feature.featureDefinition- the feature definition that is merged with the existing feature.dittoHeaders- the ditto headers.- Returns:
- the created
MergeThingcommand.
-
withFeatureProperties
public static MergeThing withFeatureProperties(ThingId thingId, String featureId, FeatureProperties featureProperties, org.eclipse.ditto.base.model.headers.DittoHeaders dittoHeaders) Creates a command for merging the feature identified bythingIdandfeatureIdwith the givenfeatureProperties.- Parameters:
thingId- the thing id.featureId- the feature id identifying the feature.featureProperties- the featureProperties that are merged with the existing feature.dittoHeaders- the ditto headers.- Returns:
- the created
MergeThingcommand.
-
withFeatureProperty
public static MergeThing withFeatureProperty(ThingId thingId, String featureId, org.eclipse.ditto.json.JsonPointer propertyPath, org.eclipse.ditto.json.JsonValue propertyValue, org.eclipse.ditto.base.model.headers.DittoHeaders dittoHeaders) Creates a command for merging the feature identified bythingIdandfeatureIdwith the givenpropertyPathandpropertyValue.- Parameters:
thingId- the thing id.featureId- the feature id identifying the feature.propertyPath- the path where the property value is merged with the existing feature properties.propertyValue- the property value that is merged with the existing feature properties.dittoHeaders- the ditto headers.- Returns:
- the created
MergeThingcommand.
-
withFeatureDesiredProperties
public static MergeThing withFeatureDesiredProperties(ThingId thingId, String featureId, FeatureProperties desiredFeatureProperties, org.eclipse.ditto.base.model.headers.DittoHeaders dittoHeaders) Creates a command for merging the feature identified bythingIdandfeatureIdwith the givendesiredFeatureProperties.- Parameters:
thingId- the thing id.featureId- the feature id identifying the feature.desiredFeatureProperties- the desired feature properties that are merged with the existing feature.dittoHeaders- the ditto headers.- Returns:
- the created
MergeThingcommand.
-
withFeatureDesiredProperty
public static MergeThing withFeatureDesiredProperty(ThingId thingId, String featureId, org.eclipse.ditto.json.JsonPointer propertyPath, org.eclipse.ditto.json.JsonValue propertyValue, org.eclipse.ditto.base.model.headers.DittoHeaders dittoHeaders) Creates a command for merging the feature identified bythingIdandfeatureIdwith the givenpropertyPathandpropertyValue.- Parameters:
thingId- the thing id.featureId- the feature id identifying the feature.propertyPath- the path where the property value is merged with the existing desired feature properties.propertyValue- the property value that is merged with the existing desired feature properties.dittoHeaders- the ditto headers.- Returns:
- the created
MergeThingcommand.
-
initialPolicyForMergeThingFrom
public static Optional<org.eclipse.ditto.json.JsonObject> initialPolicyForMergeThingFrom(org.eclipse.ditto.json.JsonObject jsonObject) Retrieves a potentially included "inline policy" from the_policyfield of the passedjsonObject.- Parameters:
jsonObject- the JSON object to look for an inline policy in.- Returns:
- the potentially contained inline policy as JSON object.
-
policyIdOrPlaceholderForMergeThingFrom
public static Optional<String> policyIdOrPlaceholderForMergeThingFrom(org.eclipse.ditto.json.JsonObject jsonObject) Retrieves a potentially included "policy id or placeholder" to copy a policy from the_copyPolicyFromfield of the passedjsonObject.- Parameters:
jsonObject- the JSON object to look for the policy id or placeholder in.- Returns:
- the potentially contained policy id or placeholder.
-
fromJson
public static MergeThing fromJson(org.eclipse.ditto.json.JsonObject jsonObject, org.eclipse.ditto.base.model.headers.DittoHeaders dittoHeaders) Creates a newMergeThingfrom a JSON object.- Parameters:
jsonObject- the JSON object of which the command is to be created.dittoHeaders- the headers of the command.- Returns:
- the
MergeThingcommand created from JSON. - Throws:
NullPointerException- ifjsonObjectisnull.org.eclipse.ditto.json.JsonParseException- if the passed injsonObjectwas not in the expected format.org.eclipse.ditto.json.JsonMissingFieldException- ifjsonObjectdid not contain a field forThingCommand.JsonFields.JSON_THING_ID,MergeThing.JsonFields.JSON_PATHorMergeThing.JsonFields.JSON_VALUE.
-
getPath
public org.eclipse.ditto.json.JsonPointer getPath()- Returns:
- the path where the changes are applied.
-
getEntityId
- Specified by:
getEntityIdin interfaceorg.eclipse.ditto.base.model.entity.id.WithEntityId- Specified by:
getEntityIdin interfaceWithThingId
-
getEntity
- Specified by:
getEntityin interfaceorg.eclipse.ditto.base.model.signals.WithOptionalEntity<MergeThing>
-
getEntity
public Optional<org.eclipse.ditto.json.JsonValue> getEntity(org.eclipse.ditto.base.model.json.JsonSchemaVersion schemaVersion) - Specified by:
getEntityin interfaceorg.eclipse.ditto.base.model.signals.WithOptionalEntity<MergeThing>
-
setEntity
- Specified by:
setEntityin interfaceorg.eclipse.ditto.base.model.signals.WithOptionalEntity<MergeThing>
-
getResourcePath
public org.eclipse.ditto.json.JsonPointer getResourcePath()- Specified by:
getResourcePathin interfaceorg.eclipse.ditto.base.model.signals.WithResource
-
getInitialPolicy
- Returns:
- the initial
Policyif there should be one applied when creating the Thing. - Since:
- 3.3.0
-
getPolicyIdOrPlaceholder
- Returns:
- The policy id of the
Policyto copy and set for the Thing when creating it. Could also be a placeholder like: {{ ref:things/theThingId/policyId }}. - Since:
- 3.3.0
-
changesAuthorization
public boolean changesAuthorization()Description copied from interface:ThingModifyCommandChecks whether this command may change authorization of the Thing.- Specified by:
changesAuthorizationin interfaceThingModifyCommand<MergeThing>- Returns:
trueif authorization would change,falseotherwise.
-
getCategory
public org.eclipse.ditto.base.model.signals.commands.Command.Category getCategory()- Specified by:
getCategoryin interfaceorg.eclipse.ditto.base.model.signals.commands.Command<MergeThing>
-
setDittoHeaders
- Specified by:
setDittoHeadersin interfaceorg.eclipse.ditto.base.model.signals.commands.Command<MergeThing>- Specified by:
setDittoHeadersin interfaceorg.eclipse.ditto.base.model.headers.DittoHeadersSettable<MergeThing>- Specified by:
setDittoHeadersin interfaceThingCommand<MergeThing>- Specified by:
setDittoHeadersin interfaceThingModifyCommand<MergeThing>
-
appendPayload
protected void appendPayload(org.eclipse.ditto.json.JsonObjectBuilder jsonObjectBuilder, org.eclipse.ditto.base.model.json.JsonSchemaVersion schemaVersion, Predicate<org.eclipse.ditto.json.JsonField> predicateParameter) - Specified by:
appendPayloadin classorg.eclipse.ditto.base.model.signals.commands.AbstractCommand<MergeThing>
-
getSupportedSchemaVersions
public org.eclipse.ditto.base.model.json.JsonSchemaVersion[] getSupportedSchemaVersions()- Specified by:
getSupportedSchemaVersionsin interfaceorg.eclipse.ditto.base.model.json.Jsonifiable<org.eclipse.ditto.json.JsonObject>
-
getValue
public org.eclipse.ditto.json.JsonValue getValue()- Returns:
- the value describing the changes that are applied to the existing thing.
-
equals
- Overrides:
equalsin classorg.eclipse.ditto.base.model.signals.commands.AbstractCommand<MergeThing>
-
canEqual
- Overrides:
canEqualin classorg.eclipse.ditto.base.model.signals.commands.AbstractCommand<MergeThing>
-
hashCode
public int hashCode()- Overrides:
hashCodein classorg.eclipse.ditto.base.model.signals.commands.AbstractCommand<MergeThing>
-
toString
- Overrides:
toStringin classorg.eclipse.ditto.base.model.signals.commands.AbstractCommand<MergeThing>
-