Class 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, 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.Category
      • Nested 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 java.lang.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 java.lang.Object>
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String NAME
      Name of the "Merge Thing" command.
      static java.lang.String TYPE
      Type of this command.
      • Fields inherited from interface org.eclipse.ditto.base.model.signals.commands.Command

        TYPE_QUALIFIER
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void appendPayload​(org.eclipse.ditto.json.JsonObjectBuilder jsonObjectBuilder, org.eclipse.ditto.base.model.json.JsonSchemaVersion schemaVersion, java.util.function.Predicate<org.eclipse.ditto.json.JsonField> predicateParameter)  
      boolean changesAuthorization()
      Checks whether this command may change authorization of the Thing.
      boolean equals​(java.lang.Object o)  
      static MergeThing fromJson​(org.eclipse.ditto.json.JsonObject jsonObject, org.eclipse.ditto.base.model.headers.DittoHeaders dittoHeaders)
      Creates a new MergeThing from a JSON object.
      org.eclipse.ditto.base.model.signals.commands.Command.Category getCategory()  
      java.util.Optional<org.eclipse.ditto.json.JsonValue> getEntity()  
      java.util.Optional<org.eclipse.ditto.json.JsonValue> getEntity​(org.eclipse.ditto.base.model.json.JsonSchemaVersion schemaVersion)  
      ThingId getEntityId()  
      org.eclipse.ditto.json.JsonPointer getPath()  
      org.eclipse.ditto.json.JsonPointer getResourcePath()  
      org.eclipse.ditto.base.model.json.JsonSchemaVersion[] getSupportedSchemaVersions()  
      org.eclipse.ditto.json.JsonValue getValue()  
      int hashCode()  
      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 by thingId with the given path and value.
      MergeThing setDittoHeaders​(org.eclipse.ditto.base.model.headers.DittoHeaders dittoHeaders)  
      java.lang.String toString()  
      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 by thingId with the given attributePath and attributeValue.
      static MergeThing withAttributes​(ThingId thingId, Attributes attributes, org.eclipse.ditto.base.model.headers.DittoHeaders dittoHeaders)
      Creates a command for merging the thing identified by thingId with the given attributes.
      static MergeThing withFeature​(ThingId thingId, Feature feature, org.eclipse.ditto.base.model.headers.DittoHeaders dittoHeaders)
      Creates a command for merging the thing identified by thingId with the given feature.
      static MergeThing withFeatureDefinition​(ThingId thingId, java.lang.String featureId, FeatureDefinition featureDefinition, org.eclipse.ditto.base.model.headers.DittoHeaders dittoHeaders)
      Creates a command for merging the feature identified by thingId and featureId with the given featureDefinition.
      static MergeThing withFeatureDesiredProperties​(ThingId thingId, java.lang.String featureId, FeatureProperties desiredFeatureProperties, org.eclipse.ditto.base.model.headers.DittoHeaders dittoHeaders)
      Creates a command for merging the feature identified by thingId and featureId with the given desiredFeatureProperties.
      static MergeThing withFeatureDesiredProperty​(ThingId thingId, java.lang.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 by thingId and featureId with the given propertyPath and propertyValue.
      static MergeThing withFeatureProperties​(ThingId thingId, java.lang.String featureId, FeatureProperties featureProperties, org.eclipse.ditto.base.model.headers.DittoHeaders dittoHeaders)
      Creates a command for merging the feature identified by thingId and featureId with the given featureProperties.
      static MergeThing withFeatureProperty​(ThingId thingId, java.lang.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 by thingId and featureId with the given propertyPath and propertyValue.
      static MergeThing withFeatures​(ThingId thingId, Features features, org.eclipse.ditto.base.model.headers.DittoHeaders dittoHeaders)
      Creates a command for merging the thing identified by thingId with the given features.
      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 by thingId with the given policyId.
      static MergeThing withThing​(ThingId thingId, Thing thing, org.eclipse.ditto.base.model.headers.DittoHeaders dittoHeaders)
      Creates a command for merging the thing identified by thingId with the given thing.
      static MergeThing withThingDefinition​(ThingId thingId, ThingDefinition thingDefinition, org.eclipse.ditto.base.model.headers.DittoHeaders dittoHeaders)
      Creates a command for merging the thing identified by thingId with the given thingDefinition.
      • Methods inherited from class org.eclipse.ditto.base.model.signals.commands.AbstractCommand

        canEqual, getDittoHeaders, getManifest, getType, toJson
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface org.eclipse.ditto.base.model.signals.commands.Command

        getImplementedSchemaVersion, toJson, toJson
      • Methods inherited from interface org.eclipse.ditto.base.model.json.Jsonifiable

        getLatestSchemaVersion, implementsSchemaVersion, implementsSchemaVersion, toJsonString
      • Methods inherited from interface org.eclipse.ditto.base.model.json.Jsonifiable.WithPredicate

        toJson, toJsonString, toJsonString
      • Methods inherited from interface org.eclipse.ditto.base.model.signals.Signal

        getName
      • Methods inherited from interface org.eclipse.ditto.base.model.headers.WithDittoHeaders

        getDittoHeaders
      • Methods inherited from interface org.eclipse.ditto.base.model.headers.WithManifest

        getManifest
      • Methods inherited from interface org.eclipse.ditto.base.model.signals.WithType

        getType
    • Field Detail

      • NAME

        public static final java.lang.String NAME
        Name of the "Merge Thing" command.
        See Also:
        Constant Field Values
    • Method Detail

      • 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 by thingId with the given path and value.
        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 MergeThing command.
      • 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 by thingId with the given thing.
        Parameters:
        thingId - the thing id.
        thing - the thing that is merged with the existing thing.
        dittoHeaders - the ditto headers.
        Returns:
        the created MergeThing command.
      • 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 by thingId with the given policyId.
        Parameters:
        thingId - the thing id.
        policyId - the policyId that is merged with the existing thing.
        dittoHeaders - the ditto headers.
        Returns:
        the created MergeThing command.
      • 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 by thingId with the given thingDefinition.
        Parameters:
        thingId - the thing id.
        thingDefinition - the thing definition that is merged with the existing thing.
        dittoHeaders - the ditto headers.
        Returns:
        the created MergeThing command.
      • 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 by thingId with the given attributes.
        Parameters:
        thingId - the thing id.
        attributes - the attributes that are merged with the existing thing.
        dittoHeaders - the ditto headers.
        Returns:
        the created MergeThing command.
      • 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 by thingId with the given attributePath and attributeValue.
        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 MergeThing command.
      • 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 by thingId with the given features.
        Parameters:
        thingId - the thing id.
        features - the features that are merged with the existing thing.
        dittoHeaders - the ditto headers.
        Returns:
        the created MergeThing command.
      • 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 by thingId with the given feature.
        Parameters:
        thingId - the thing id.
        feature - the feature that is merged with the existing thing.
        dittoHeaders - the ditto headers.
        Returns:
        the created MergeThing command.
      • withFeatureDefinition

        public static MergeThing withFeatureDefinition​(ThingId thingId,
                                                       java.lang.String featureId,
                                                       FeatureDefinition featureDefinition,
                                                       org.eclipse.ditto.base.model.headers.DittoHeaders dittoHeaders)
        Creates a command for merging the feature identified by thingId and featureId with the given featureDefinition.
        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 MergeThing command.
      • withFeatureProperties

        public static MergeThing withFeatureProperties​(ThingId thingId,
                                                       java.lang.String featureId,
                                                       FeatureProperties featureProperties,
                                                       org.eclipse.ditto.base.model.headers.DittoHeaders dittoHeaders)
        Creates a command for merging the feature identified by thingId and featureId with the given featureProperties.
        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 MergeThing command.
      • withFeatureProperty

        public static MergeThing withFeatureProperty​(ThingId thingId,
                                                     java.lang.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 by thingId and featureId with the given propertyPath and propertyValue.
        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 MergeThing command.
      • withFeatureDesiredProperties

        public static MergeThing withFeatureDesiredProperties​(ThingId thingId,
                                                              java.lang.String featureId,
                                                              FeatureProperties desiredFeatureProperties,
                                                              org.eclipse.ditto.base.model.headers.DittoHeaders dittoHeaders)
        Creates a command for merging the feature identified by thingId and featureId with the given desiredFeatureProperties.
        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 MergeThing command.
      • withFeatureDesiredProperty

        public static MergeThing withFeatureDesiredProperty​(ThingId thingId,
                                                            java.lang.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 by thingId and featureId with the given propertyPath and propertyValue.
        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 MergeThing command.
      • fromJson

        public static MergeThing fromJson​(org.eclipse.ditto.json.JsonObject jsonObject,
                                          org.eclipse.ditto.base.model.headers.DittoHeaders dittoHeaders)
        Creates a new MergeThing from a JSON object.
        Parameters:
        jsonObject - the JSON object of which the command is to be created.
        dittoHeaders - the headers of the command.
        Returns:
        the MergeThing command created from JSON.
        Throws:
        java.lang.NullPointerException - if jsonObject is null.
        org.eclipse.ditto.json.JsonParseException - if the passed in jsonObject was not in the expected format.
        org.eclipse.ditto.json.JsonMissingFieldException - if jsonObject did not contain a field for ThingCommand.JsonFields.JSON_THING_ID, MergeThing.JsonFields.JSON_PATH or MergeThing.JsonFields.JSON_VALUE.
      • getPath

        public org.eclipse.ditto.json.JsonPointer getPath()
        Returns:
        the path where the changes are applied.
      • getEntityId

        public ThingId getEntityId()
        Specified by:
        getEntityId in interface org.eclipse.ditto.base.model.entity.id.WithEntityId
        Specified by:
        getEntityId in interface WithThingId
      • getEntity

        public java.util.Optional<org.eclipse.ditto.json.JsonValue> getEntity()
        Specified by:
        getEntity in interface org.eclipse.ditto.base.model.signals.WithOptionalEntity
      • getEntity

        public java.util.Optional<org.eclipse.ditto.json.JsonValue> getEntity​(org.eclipse.ditto.base.model.json.JsonSchemaVersion schemaVersion)
        Specified by:
        getEntity in interface org.eclipse.ditto.base.model.signals.WithOptionalEntity
      • getResourcePath

        public org.eclipse.ditto.json.JsonPointer getResourcePath()
        Specified by:
        getResourcePath in interface org.eclipse.ditto.base.model.signals.WithResource
      • getCategory

        public org.eclipse.ditto.base.model.signals.commands.Command.Category getCategory()
        Specified by:
        getCategory in interface org.eclipse.ditto.base.model.signals.commands.Command<MergeThing>
      • appendPayload

        protected void appendPayload​(org.eclipse.ditto.json.JsonObjectBuilder jsonObjectBuilder,
                                     org.eclipse.ditto.base.model.json.JsonSchemaVersion schemaVersion,
                                     java.util.function.Predicate<org.eclipse.ditto.json.JsonField> predicateParameter)
        Specified by:
        appendPayload in class org.eclipse.ditto.base.model.signals.commands.AbstractCommand<MergeThing>
      • getSupportedSchemaVersions

        public org.eclipse.ditto.base.model.json.JsonSchemaVersion[] getSupportedSchemaVersions()
        Specified by:
        getSupportedSchemaVersions in interface org.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

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class org.eclipse.ditto.base.model.signals.commands.AbstractCommand<MergeThing>
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class org.eclipse.ditto.base.model.signals.commands.AbstractCommand<MergeThing>
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class org.eclipse.ditto.base.model.signals.commands.AbstractCommand<MergeThing>