Class CreateThing

  • 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<CreateThing>, 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<CreateThing>, org.eclipse.ditto.base.model.signals.Signal<CreateThing>, org.eclipse.ditto.base.model.signals.SignalWithEntityId<CreateThing>, 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<CreateThing>, ThingCommand<CreateThing>, WithThingId

    @Immutable
    public final class CreateThing
    extends org.eclipse.ditto.base.model.signals.commands.AbstractCommand<CreateThing>
    implements ThingModifyCommand<CreateThing>
    This command creates a new Thing. It contains the full Thing including the Thing ID which should be used for creation. If the Thing ID is already in the system, a response with a status code 409 (Conflict) will be generated.
    • 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, org.eclipse.ditto.base.model.signals.commands.Command.JsonFields
      • 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 org.eclipse.ditto.json.JsonFieldDefinition<java.lang.String> JSON_COPY_POLICY_FROM
      Json Field definition for the optional feature to copy an existing policy.
      static org.eclipse.ditto.json.JsonFieldDefinition<org.eclipse.ditto.json.JsonObject> JSON_INITIAL_POLICY
      Json Field definition for the optional initial "inline" policy when creating a Thing.
      static org.eclipse.ditto.json.JsonFieldDefinition<org.eclipse.ditto.json.JsonObject> JSON_INLINE_POLICY
      Json Field definition for the optional initial "inline" policy for usage in getEntity().
      static org.eclipse.ditto.json.JsonFieldDefinition<java.lang.String> JSON_POLICY_ID_OR_PLACEHOLDER
      Json Field definition for the optional feature to copy an existing policy.
      static org.eclipse.ditto.json.JsonFieldDefinition<org.eclipse.ditto.json.JsonObject> JSON_THING  
      static java.lang.String NAME
      Name of the "Create 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> thePredicate)  
      protected boolean canEqual​(java.lang.Object other)  
      boolean changesAuthorization()
      Checks whether this command may change authorization of the Thing.
      boolean equals​(java.lang.Object obj)  
      static CreateThing fromJson​(java.lang.String jsonString, org.eclipse.ditto.base.model.headers.DittoHeaders dittoHeaders)
      Creates a new CreateThing from a JSON string.
      static CreateThing fromJson​(org.eclipse.ditto.json.JsonObject jsonObject, org.eclipse.ditto.base.model.headers.DittoHeaders dittoHeaders)
      Creates a new CreateThing from a JSON object.
      org.eclipse.ditto.base.model.signals.commands.Command.Category getCategory()  
      java.util.Optional<org.eclipse.ditto.json.JsonValue> getEntity​(org.eclipse.ditto.base.model.json.JsonSchemaVersion schemaVersion)  
      ThingId getEntityId()  
      java.util.Optional<org.eclipse.ditto.json.JsonObject> getInitialPolicy()  
      java.util.Optional<java.lang.String> getPolicyIdOrPlaceholder()  
      org.eclipse.ditto.json.JsonPointer getResourcePath()  
      Thing getThing()
      Returns the Thing to create.
      int hashCode()  
      static CreateThing of​(Thing newThing, org.eclipse.ditto.json.JsonObject initialPolicy, java.lang.String policyIdOrPlaceholder, org.eclipse.ditto.base.model.headers.DittoHeaders dittoHeaders)
      Returns a Command for creating a new Thing which is passed as argument.
      static CreateThing of​(Thing newThing, org.eclipse.ditto.json.JsonObject initialPolicy, org.eclipse.ditto.base.model.headers.DittoHeaders dittoHeaders)
      Returns a Command for creating a new Thing which is passed as argument.
      CreateThing setDittoHeaders​(org.eclipse.ditto.base.model.headers.DittoHeaders dittoHeaders)  
      java.lang.String toString()  
      static CreateThing withCopiedPolicy​(Thing newThing, java.lang.String policyIdOrPlaceholder, org.eclipse.ditto.base.model.headers.DittoHeaders dittoHeaders)
      Returns a Command for creating a new Thing which is passed as argument.
      • Methods inherited from class org.eclipse.ditto.base.model.signals.commands.AbstractCommand

        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, getSupportedSchemaVersions, 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.WithOptionalEntity

        getEntity
      • 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 "Create Thing" command.
        See Also:
        Constant Field Values
      • JSON_THING

        public static final org.eclipse.ditto.json.JsonFieldDefinition<org.eclipse.ditto.json.JsonObject> JSON_THING
      • JSON_POLICY_ID_OR_PLACEHOLDER

        public static final org.eclipse.ditto.json.JsonFieldDefinition<java.lang.String> JSON_POLICY_ID_OR_PLACEHOLDER
        Json Field definition for the optional feature to copy an existing policy.
      • JSON_COPY_POLICY_FROM

        public static final org.eclipse.ditto.json.JsonFieldDefinition<java.lang.String> JSON_COPY_POLICY_FROM
        Json Field definition for the optional feature to copy an existing policy.
      • JSON_INITIAL_POLICY

        public static final org.eclipse.ditto.json.JsonFieldDefinition<org.eclipse.ditto.json.JsonObject> JSON_INITIAL_POLICY
        Json Field definition for the optional initial "inline" policy when creating a Thing.
      • JSON_INLINE_POLICY

        public static final org.eclipse.ditto.json.JsonFieldDefinition<org.eclipse.ditto.json.JsonObject> JSON_INLINE_POLICY
        Json Field definition for the optional initial "inline" policy for usage in getEntity().
    • Method Detail

      • of

        public static CreateThing of​(Thing newThing,
                                     @Nullable
                                     org.eclipse.ditto.json.JsonObject initialPolicy,
                                     org.eclipse.ditto.base.model.headers.DittoHeaders dittoHeaders)
        Returns a Command for creating a new Thing which is passed as argument.
        Parameters:
        newThing - the new Thing to create.
        initialPolicy - the initial Policy to set for the Thing - may be null.
        dittoHeaders - the headers of the command.
        Returns:
        a Command for creating the provided new Thing.
        Throws:
        java.lang.NullPointerException - if any argument is null.
        ThingIdInvalidException - if the Thing's ID is not valid.
      • withCopiedPolicy

        public static CreateThing withCopiedPolicy​(Thing newThing,
                                                   java.lang.String policyIdOrPlaceholder,
                                                   org.eclipse.ditto.base.model.headers.DittoHeaders dittoHeaders)
        Returns a Command for creating a new Thing which is passed as argument. The created thing will have a policy copied from a policy with athe given policyIdOrPlaceholder.
        Parameters:
        newThing - the new Thing to create.
        policyIdOrPlaceholder - the policy id of the Policy to copy and set for the Thing when creating it. If its a placeholder it will be resolved to a policy id. Placeholder must be of the syntax: {{ ref:things/theThingId/policyId }}.
        dittoHeaders - the headers of the command.
        Returns:
        a Command for creating the provided new Thing.
        Throws:
        java.lang.NullPointerException - if any argument is null.
        ThingIdInvalidException - if the Thing's ID is not valid.
      • of

        public static CreateThing of​(Thing newThing,
                                     @Nullable
                                     org.eclipse.ditto.json.JsonObject initialPolicy,
                                     @Nullable
                                     java.lang.String policyIdOrPlaceholder,
                                     org.eclipse.ditto.base.model.headers.DittoHeaders dittoHeaders)
        Returns a Command for creating a new Thing which is passed as argument. The created thing will have a policy copied from a policy with a given policyIdOrPlaceholder.
        Parameters:
        newThing - the new Thing to create.
        initialPolicy - the initial Policy to set for the Thing - may be null.
        policyIdOrPlaceholder - the policy id of the Policy to copy and set for the Thing when creating it. If its a placeholder it will be resolved to a policy id. Placeholder must be of the syntax: {{ ref:things/theThingId/policyId }}.
        dittoHeaders - the headers of the command.
        Returns:
        a Command for creating the provided new Thing.
        Throws:
        java.lang.NullPointerException - if any argument is null.
        ThingIdInvalidException - if the Thing's ID is not valid.
      • fromJson

        public static CreateThing fromJson​(java.lang.String jsonString,
                                           org.eclipse.ditto.base.model.headers.DittoHeaders dittoHeaders)
        Creates a new CreateThing from a JSON string.
        Parameters:
        jsonString - the JSON string of which the command is to be created.
        dittoHeaders - the headers of the command.
        Returns:
        the command.
        Throws:
        java.lang.NullPointerException - if jsonString is null.
        java.lang.IllegalArgumentException - if jsonString is empty.
        org.eclipse.ditto.json.JsonParseException - if the passed in jsonString was not in the expected format.
      • fromJson

        public static CreateThing fromJson​(org.eclipse.ditto.json.JsonObject jsonObject,
                                           org.eclipse.ditto.base.model.headers.DittoHeaders dittoHeaders)
        Creates a new CreateThing 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 command.
        Throws:
        java.lang.NullPointerException - if jsonObject is null.
        org.eclipse.ditto.json.JsonParseException - if the passed in jsonObject was not in the expected format.
      • getThing

        public Thing getThing()
        Returns the Thing to create.
        Returns:
        the Thing to create.
      • getInitialPolicy

        public java.util.Optional<org.eclipse.ditto.json.JsonObject> getInitialPolicy()
        Returns:
        the initial Policy if there should be one applied when creating the Thing.
      • getPolicyIdOrPlaceholder

        public java.util.Optional<java.lang.String> getPolicyIdOrPlaceholder()
        Returns:
        the policyIdOrPlaceholder that should be used to copy an existing policy when creating the Thing.
      • 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​(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
      • 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> thePredicate)
        Specified by:
        appendPayload in class org.eclipse.ditto.base.model.signals.commands.AbstractCommand<CreateThing>
      • 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<CreateThing>
      • hashCode

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

        public boolean equals​(@Nullable
                              java.lang.Object obj)
        Overrides:
        equals in class org.eclipse.ditto.base.model.signals.commands.AbstractCommand<CreateThing>
      • canEqual

        protected boolean canEqual​(@Nullable
                                   java.lang.Object other)
        Overrides:
        canEqual in class org.eclipse.ditto.base.model.signals.commands.AbstractCommand<CreateThing>
      • toString

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