Class CreateThing
- java.lang.Object
-
- org.eclipse.ditto.signals.commands.base.AbstractCommand<CreateThing>
-
- org.eclipse.ditto.signals.commands.things.modify.CreateThing
-
- All Implemented Interfaces:
org.eclipse.ditto.model.base.entity.type.WithEntityType
,org.eclipse.ditto.model.base.headers.WithDittoHeaders<CreateThing>
,org.eclipse.ditto.model.base.headers.WithManifest
,org.eclipse.ditto.model.base.json.Jsonifiable<org.eclipse.ditto.json.JsonObject>
,org.eclipse.ditto.model.base.json.Jsonifiable.WithPredicate<org.eclipse.ditto.json.JsonObject,org.eclipse.ditto.json.JsonField>
,org.eclipse.ditto.model.things.WithThingId
,org.eclipse.ditto.signals.base.Signal<CreateThing>
,org.eclipse.ditto.signals.base.WithId
,org.eclipse.ditto.signals.base.WithName
,org.eclipse.ditto.signals.base.WithOptionalEntity
,org.eclipse.ditto.signals.base.WithResource
,org.eclipse.ditto.signals.base.WithType
,org.eclipse.ditto.signals.commands.base.Command<CreateThing>
,ThingModifyCommand<CreateThing>
,ThingCommand<CreateThing>
@Immutable public final class CreateThing extends org.eclipse.ditto.signals.commands.base.AbstractCommand<CreateThing> implements ThingModifyCommand<CreateThing>
This command creates a new Thing. It contains the fullThing
including the Thing ID which should be used for creation. If the Thing ID is already in the system, a response with a status code409
(Conflict) will be generated.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.eclipse.ditto.signals.commands.base.Command
org.eclipse.ditto.signals.commands.base.Command.Category, org.eclipse.ditto.signals.commands.base.Command.JsonFields
-
Nested classes/interfaces inherited from interface org.eclipse.ditto.model.base.json.Jsonifiable
org.eclipse.ditto.model.base.json.Jsonifiable.WithFieldSelector, org.eclipse.ditto.model.base.json.Jsonifiable.WithFieldSelectorAndPredicate<T extends Object>, org.eclipse.ditto.model.base.json.Jsonifiable.WithPointer<J extends org.eclipse.ditto.json.JsonValue>, org.eclipse.ditto.model.base.json.Jsonifiable.WithPredicate<J extends org.eclipse.ditto.json.JsonValue,T extends Object>
-
Nested classes/interfaces inherited from interface org.eclipse.ditto.signals.commands.things.ThingCommand
ThingCommand.JsonFields
-
-
Field Summary
Fields Modifier and Type Field Description static org.eclipse.ditto.json.JsonFieldDefinition<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<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 String
NAME
Name of the "Create Thing" command.static String
TYPE
Type of this command.-
Fields inherited from interface org.eclipse.ditto.signals.commands.things.ThingCommand
RESOURCE_TYPE, TYPE_PREFIX
-
-
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.model.base.json.JsonSchemaVersion schemaVersion, Predicate<org.eclipse.ditto.json.JsonField> thePredicate)
protected boolean
canEqual(Object other)
boolean
changesAuthorization()
Checks whether this command may change authorization of the Thing.boolean
equals(Object obj)
static CreateThing
fromJson(String jsonString, org.eclipse.ditto.model.base.headers.DittoHeaders dittoHeaders)
Creates a newCreateThing
from a JSON string.static CreateThing
fromJson(org.eclipse.ditto.json.JsonObject jsonObject, org.eclipse.ditto.model.base.headers.DittoHeaders dittoHeaders)
Creates a newCreateThing
from a JSON object.org.eclipse.ditto.signals.commands.base.Command.Category
getCategory()
Optional<org.eclipse.ditto.json.JsonValue>
getEntity(org.eclipse.ditto.model.base.json.JsonSchemaVersion schemaVersion)
Optional<org.eclipse.ditto.json.JsonObject>
getInitialPolicy()
Optional<String>
getPolicyIdOrPlaceholder()
org.eclipse.ditto.json.JsonPointer
getResourcePath()
org.eclipse.ditto.model.things.Thing
getThing()
Returns theThing
to create.org.eclipse.ditto.model.things.ThingId
getThingEntityId()
int
hashCode()
static CreateThing
of(org.eclipse.ditto.model.things.Thing newThing, org.eclipse.ditto.json.JsonObject initialPolicy, String policyIdOrPlaceholder, org.eclipse.ditto.model.base.headers.DittoHeaders dittoHeaders)
Returns a Command for creating a new Thing which is passed as argument.static CreateThing
of(org.eclipse.ditto.model.things.Thing newThing, org.eclipse.ditto.json.JsonObject initialPolicy, org.eclipse.ditto.model.base.headers.DittoHeaders dittoHeaders)
Returns a Command for creating a new Thing which is passed as argument.CreateThing
setDittoHeaders(org.eclipse.ditto.model.base.headers.DittoHeaders dittoHeaders)
String
toString()
static CreateThing
withCopiedPolicy(org.eclipse.ditto.model.things.Thing newThing, String policyIdOrPlaceholder, org.eclipse.ditto.model.base.headers.DittoHeaders dittoHeaders)
Returns a Command for creating a new Thing which is passed as argument.-
Methods inherited from class org.eclipse.ditto.signals.commands.base.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.signals.commands.base.Command
getImplementedSchemaVersion, toJson, toJson
-
Methods inherited from interface org.eclipse.ditto.model.base.json.Jsonifiable
getLatestSchemaVersion, getSupportedSchemaVersions, implementsSchemaVersion, implementsSchemaVersion, toJsonString
-
Methods inherited from interface org.eclipse.ditto.model.base.json.Jsonifiable.WithPredicate
toJson, toJsonString, toJsonString
-
Methods inherited from interface org.eclipse.ditto.signals.commands.things.ThingCommand
getEntityId, getEntityType, getResourceType, getTypePrefix
-
-
-
-
Field Detail
-
NAME
public static final String NAME
Name of the "Create Thing" command.- See Also:
- Constant Field Values
-
TYPE
public static final String TYPE
Type of this 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<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<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(org.eclipse.ditto.model.things.Thing newThing, @Nullable org.eclipse.ditto.json.JsonObject initialPolicy, org.eclipse.ditto.model.base.headers.DittoHeaders dittoHeaders)
Returns a Command for creating a new Thing which is passed as argument.- Parameters:
newThing
- the newThing
to create.initialPolicy
- the initialPolicy
to set for the Thing - may be null.dittoHeaders
- the headers of the command.- Returns:
- a Command for creating the provided new Thing.
- Throws:
NullPointerException
- if any argument isnull
.org.eclipse.ditto.model.things.ThingIdInvalidException
- if theThing
's ID is not valid.org.eclipse.ditto.model.things.AclInvalidException
- if the Access Control List ofthing
does not contain at least one authorization subject which has the permissionsPermission.READ
,Permission.WRITE
andPermission.WRITE
.
-
withCopiedPolicy
public static CreateThing withCopiedPolicy(org.eclipse.ditto.model.things.Thing newThing, String policyIdOrPlaceholder, org.eclipse.ditto.model.base.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 newThing
to create.policyIdOrPlaceholder
- the policy id of thePolicy
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:
NullPointerException
- if any argument isnull
.org.eclipse.ditto.model.things.ThingIdInvalidException
- if theThing
's ID is not valid.org.eclipse.ditto.model.things.AclInvalidException
- if the Access Control List ofthing
does not contain at least one authorization subject which has the permissionsPermission.READ
,Permission.WRITE
andPermission.WRITE
.
-
of
public static CreateThing of(org.eclipse.ditto.model.things.Thing newThing, @Nullable org.eclipse.ditto.json.JsonObject initialPolicy, @Nullable String policyIdOrPlaceholder, org.eclipse.ditto.model.base.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 newThing
to create.initialPolicy
- the initialPolicy
to set for the Thing - may be null.policyIdOrPlaceholder
- the policy id of thePolicy
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:
NullPointerException
- if any argument isnull
.org.eclipse.ditto.model.things.ThingIdInvalidException
- if theThing
's ID is not valid.org.eclipse.ditto.model.things.AclInvalidException
- if the Access Control List ofthing
does not contain at least one authorization subject which has the permissionsPermission.READ
,Permission.WRITE
andPermission.WRITE
.
-
fromJson
public static CreateThing fromJson(String jsonString, org.eclipse.ditto.model.base.headers.DittoHeaders dittoHeaders)
Creates a newCreateThing
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:
NullPointerException
- ifjsonString
isnull
.IllegalArgumentException
- ifjsonString
is empty.org.eclipse.ditto.json.JsonParseException
- if the passed injsonString
was not in the expected format.
-
fromJson
public static CreateThing fromJson(org.eclipse.ditto.json.JsonObject jsonObject, org.eclipse.ditto.model.base.headers.DittoHeaders dittoHeaders)
Creates a newCreateThing
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:
NullPointerException
- ifjsonObject
isnull
.org.eclipse.ditto.json.JsonParseException
- if the passed injsonObject
was not in the expected format.
-
getThing
public org.eclipse.ditto.model.things.Thing getThing()
Returns theThing
to create.- Returns:
- the Thing to create.
-
getInitialPolicy
public Optional<org.eclipse.ditto.json.JsonObject> getInitialPolicy()
- Returns:
- the initial
Policy
if there should be one applied when creating the Thing.
-
getPolicyIdOrPlaceholder
public Optional<String> getPolicyIdOrPlaceholder()
- Returns:
- the policyIdOrPlaceholder that should be used to copy an existing policy when creating the Thing.
-
getThingEntityId
public org.eclipse.ditto.model.things.ThingId getThingEntityId()
- Specified by:
getThingEntityId
in interfaceorg.eclipse.ditto.model.things.WithThingId
-
getEntity
public Optional<org.eclipse.ditto.json.JsonValue> getEntity(org.eclipse.ditto.model.base.json.JsonSchemaVersion schemaVersion)
- Specified by:
getEntity
in interfaceorg.eclipse.ditto.signals.base.WithOptionalEntity
-
getResourcePath
public org.eclipse.ditto.json.JsonPointer getResourcePath()
- Specified by:
getResourcePath
in interfaceorg.eclipse.ditto.signals.base.WithResource
-
appendPayload
protected void appendPayload(org.eclipse.ditto.json.JsonObjectBuilder jsonObjectBuilder, org.eclipse.ditto.model.base.json.JsonSchemaVersion schemaVersion, Predicate<org.eclipse.ditto.json.JsonField> thePredicate)
- Specified by:
appendPayload
in classorg.eclipse.ditto.signals.commands.base.AbstractCommand<CreateThing>
-
getCategory
public org.eclipse.ditto.signals.commands.base.Command.Category getCategory()
- Specified by:
getCategory
in interfaceorg.eclipse.ditto.signals.commands.base.Command<CreateThing>
-
setDittoHeaders
public CreateThing setDittoHeaders(org.eclipse.ditto.model.base.headers.DittoHeaders dittoHeaders)
- Specified by:
setDittoHeaders
in interfaceorg.eclipse.ditto.signals.commands.base.Command<CreateThing>
- Specified by:
setDittoHeaders
in interfaceThingCommand<CreateThing>
- Specified by:
setDittoHeaders
in interfaceThingModifyCommand<CreateThing>
- Specified by:
setDittoHeaders
in interfaceorg.eclipse.ditto.model.base.headers.WithDittoHeaders<CreateThing>
-
changesAuthorization
public boolean changesAuthorization()
Description copied from interface:ThingModifyCommand
Checks whether this command may change authorization of the Thing.- Specified by:
changesAuthorization
in interfaceThingModifyCommand<CreateThing>
- Returns:
true
if authorization would change,false
otherwise.
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classorg.eclipse.ditto.signals.commands.base.AbstractCommand<CreateThing>
-
equals
public boolean equals(@Nullable Object obj)
- Overrides:
equals
in classorg.eclipse.ditto.signals.commands.base.AbstractCommand<CreateThing>
-
canEqual
protected boolean canEqual(@Nullable Object other)
- Overrides:
canEqual
in classorg.eclipse.ditto.signals.commands.base.AbstractCommand<CreateThing>
-
toString
public String toString()
- Overrides:
toString
in classorg.eclipse.ditto.signals.commands.base.AbstractCommand<CreateThing>
-
-