Package org.eclipse.ditto.model.things
Interface ThingBuilder.FromScratch
-
- Enclosing interface:
- ThingBuilder
@NotThreadSafe public static interface ThingBuilder.FromScratch
A mutable builder with a fluent API for an immutableThing
from scratch.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description Thing
build()
Creates a new immutableThing
containing all properties which were set to this builder beforehand.ThingBuilder.FromScratch
removeAllAttributes()
Removes all attributes from this builder.ThingBuilder.FromScratch
removeAllFeatures()
Removes all features from this builder.ThingBuilder.FromScratch
removeAllPermissions()
Deprecated.Permissions belong to deprecated API version 1.ThingBuilder.FromScratch
removeAttribute(org.eclipse.ditto.json.JsonPointer attributePath)
Removes the attribute at the given path from this builder.ThingBuilder.FromScratch
removeDefinition()
Removes the Definition from this builder.ThingBuilder.FromScratch
removeFeature(String featureId)
Removes the Feature with the given ID from this builder.ThingBuilder.FromScratch
removeFeatureDefinition(String featureId)
Removes the definition from Feature with the given identifier on this builder.ThingBuilder.FromScratch
removeFeatureProperties(String featureId)
Removes all properties from the Feature with the given ID on this builder.ThingBuilder.FromScratch
removeFeatureProperty(String featureId, org.eclipse.ditto.json.JsonPointer propertyPath)
Removes the given property from the Feature with the given ID on this builder.ThingBuilder.FromScratch
removePermissionsOf(org.eclipse.ditto.model.base.auth.AuthorizationSubject authorizationSubject)
Deprecated.Permissions belong to deprecated API version 1.ThingBuilder.FromScratch
removePolicyId()
Removes the Policy ID from this builder.ThingBuilder.FromScratch
setAttribute(org.eclipse.ditto.json.JsonPointer attributePath, org.eclipse.ditto.json.JsonValue attributeValue)
Sets the given attribute to this builder.ThingBuilder.FromScratch
setAttributes(String attributesJsonString)
Sets the attributes to this builder.ThingBuilder.FromScratch
setAttributes(org.eclipse.ditto.json.JsonObject attributesJsonObject)
Sets the attributes to this builder.ThingBuilder.FromScratch
setAttributes(Attributes attributes)
Sets the given attributes to this builder.ThingBuilder.FromScratch
setDefinition(ThingDefinition definition)
Sets the given ThingDefinition to this builder.ThingBuilder.FromScratch
setEmptyAttributes()
Sets empty attributes to this builder.ThingBuilder.FromScratch
setEmptyFeatures()
Sets empty features to this builder.ThingBuilder.FromScratch
setFeature(String featureId)
Sets a Feature with the given ID to this builder.ThingBuilder.FromScratch
setFeature(String featureId, FeatureDefinition featureDefinition, FeatureProperties featureProperties)
Sets a Feature with the given ID and properties to this builder.ThingBuilder.FromScratch
setFeature(String featureId, FeatureProperties featureProperties)
Sets a Feature with the given ID and properties to this builder.ThingBuilder.FromScratch
setFeature(Feature feature)
Sets the given Feature to this builder.ThingBuilder.FromScratch
setFeatureDefinition(String featureId, FeatureDefinition featureDefinition)
Sets the given definition to the Feature with the given ID on this builder.ThingBuilder.FromScratch
setFeatureProperties(String featureId, FeatureProperties featureProperties)
Sets the given properties to the Feature with the given ID on this builder.ThingBuilder.FromScratch
setFeatureProperty(String featureId, org.eclipse.ditto.json.JsonPointer propertyPath, org.eclipse.ditto.json.JsonValue propertyValue)
Sets the given property to the Feature with the given ID on this builder.ThingBuilder.FromScratch
setFeatures(Iterable<Feature> features)
Sets the given Features to this builder.ThingBuilder.FromScratch
setFeatures(String featuresJsonString)
Sets the Features of the Thing based on the given JSON object.ThingBuilder.FromScratch
setFeatures(org.eclipse.ditto.json.JsonObject featuresJsonObject)
Sets the features to this builder.ThingBuilder.FromScratch
setGeneratedId()
Sets a generated Thing ID to this builder.default ThingBuilder.FromScratch
setId(String thingId)
Deprecated.thing ID is now typed.ThingBuilder.FromScratch
setId(ThingId thingId)
Sets the given Thing ID to this builder.ThingBuilder.FromScratch
setLifecycle(ThingLifecycle lifecycle)
Sets the given lifecycle to this builder.ThingBuilder.FromScratch
setModified(Instant modified)
Sets the given modified to this builder.ThingBuilder.FromScratch
setNullAttributes()
Sets attributes to this builder which represent semanticallynull
.ThingBuilder.FromScratch
setNullDefinition()
Sets the ThingDefinition to this builder which represent semanticallynull
.ThingBuilder.FromScratch
setNullFeatures()
Sets features to this builder which represents semanticallynull
.ThingBuilder.FromScratch
setPermissions(Iterable<AclEntry> aclEntries)
Deprecated.Permissions belong to deprecated API version 1.ThingBuilder.FromScratch
setPermissions(String accessControlListJsonString)
Deprecated.Permissions belong to deprecated API version 1.ThingBuilder.FromScratch
setPermissions(org.eclipse.ditto.json.JsonObject accessControlListJsonObject)
Deprecated.Permissions belong to deprecated API version 1.ThingBuilder.FromScratch
setPermissions(org.eclipse.ditto.model.base.auth.AuthorizationSubject authorizationSubject, Permission permission, Permission... furtherPermissions)
Deprecated.Permissions belong to deprecated API version 1.ThingBuilder.FromScratch
setPermissions(org.eclipse.ditto.model.base.auth.AuthorizationSubject authorizationSubject, Permissions permissions)
Deprecated.Permissions belong to deprecated API version 1.ThingBuilder.FromScratch
setPermissions(AclEntry aclEntry, AclEntry... furtherAclEntries)
Deprecated.Permissions belong to deprecated API version 1.default ThingBuilder.FromScratch
setPolicyId(String policyId)
Deprecated.Policy ID of the Thing is now typed.ThingBuilder.FromScratch
setPolicyId(org.eclipse.ditto.model.policies.PolicyId policyId)
Sets the given Policy ID to this builder.ThingBuilder.FromScratch
setRevision(long revisionNumber)
Sets the given revision number to this builder.ThingBuilder.FromScratch
setRevision(ThingRevision revision)
Sets the given revision to this builder.
-
-
-
Method Detail
-
setPermissions
@Deprecated ThingBuilder.FromScratch setPermissions(org.eclipse.ditto.model.base.auth.AuthorizationSubject authorizationSubject, Permission permission, Permission... furtherPermissions)
Deprecated.Permissions belong to deprecated API version 1. Use API version 2 with policies instead.Sets the given permissions to this builder. Previously set permissions for the same authorization subject are replaced.- Parameters:
authorizationSubject
- the authorization subject to set the permissions for.permission
- the permission of the authorization subject to be set.furtherPermissions
- additional permissions of the authorization subject to be set.- Returns:
- this builder to allow method chaining.
- Throws:
NullPointerException
- if any argument isnull
.
-
setPermissions
@Deprecated ThingBuilder.FromScratch setPermissions(org.eclipse.ditto.model.base.auth.AuthorizationSubject authorizationSubject, Permissions permissions)
Deprecated.Permissions belong to deprecated API version 1. Use API version 2 with policies instead.Sets the given permissions to this builder. Previously set permissions for the same authorization subject are replaced.- Parameters:
authorizationSubject
- the authorization subject to set the permissions for.permissions
- the permission of of the authorization subject to be set.- Returns:
- this builder to allow method chaining.
- Throws:
NullPointerException
- if any argument isnull
.
-
setPermissions
@Deprecated ThingBuilder.FromScratch setPermissions(Iterable<AclEntry> aclEntries)
Deprecated.Permissions belong to deprecated API version 1. Use API version 2 with policies instead.Sets the given permissions to this builder. All previously set ACL entries with the same authorization subject are replaced.- Parameters:
aclEntries
- the entries to be set.- Returns:
- this builder to allow method chaining.
- Throws:
NullPointerException
- ifaclEntries
isnull
.
-
setPermissions
@Deprecated ThingBuilder.FromScratch setPermissions(org.eclipse.ditto.json.JsonObject accessControlListJsonObject)
Deprecated.Permissions belong to deprecated API version 1. Use API version 2 with policies instead.Sets permissions to this builder. The permissions are parsed from the JSON object representation of an Access Control List. All previously set ACL entries with the same authorization subject are replaced.- Parameters:
accessControlListJsonObject
- the JSON object representation of an Access Control List.- Returns:
- this builder to allow method chaining.
- Throws:
NullPointerException
- ifaccessControlListJsonObject
isnull
.org.eclipse.ditto.model.base.exceptions.DittoJsonException
- ifaccessControlListJsonObject
cannot be parsed toAccessControlList
.
-
setPermissions
@Deprecated ThingBuilder.FromScratch setPermissions(String accessControlListJsonString)
Deprecated.Permissions belong to deprecated API version 1. Use API version 2 with policies instead.Sets permissions to this builder. The permissions are parsed from the JSON string representation of an Access Control List. All previously set ACL entries with the same authorization subject are replaced.- Parameters:
accessControlListJsonString
- the JSON string representation of an Access Control List.- Returns:
- this builder to allow method chaining.
- Throws:
org.eclipse.ditto.model.base.exceptions.DittoJsonException
- ifaccessControlListJsonString
cannot be parsed toAccessControlList
.- See Also:
setPermissions(JsonObject)
-
setPermissions
@Deprecated ThingBuilder.FromScratch setPermissions(AclEntry aclEntry, AclEntry... furtherAclEntries)
Deprecated.Permissions belong to deprecated API version 1. Use API version 2 with policies instead.Sets the given permissions to this builder. All previously set ACL entries with the same authorization subject are replaced.- Parameters:
aclEntry
- the ACL entry of the be set.furtherAclEntries
- additional ACL entries to be set.- Returns:
- this builder to allow method chaining.
- Throws:
NullPointerException
- if any argument isnull
.
-
removePermissionsOf
@Deprecated ThingBuilder.FromScratch removePermissionsOf(org.eclipse.ditto.model.base.auth.AuthorizationSubject authorizationSubject)
Deprecated.Permissions belong to deprecated API version 1. Use API version 2 with policies instead.Removes all permissions of the given authorization subject from this builder.- Parameters:
authorizationSubject
- the authorization subject of which all permissions are to be removed.- Returns:
- this builder to allow method chaining.
- Throws:
NullPointerException
- ifauthorizationSubject
isnull
.
-
removeAllPermissions
@Deprecated ThingBuilder.FromScratch removeAllPermissions()
Deprecated.Permissions belong to deprecated API version 1. Use API version 2 with policies instead.Removes all permissions from this builder.- Returns:
- this builder to allow method chaining.
-
setPolicyId
@Deprecated default ThingBuilder.FromScratch setPolicyId(@Nullable String policyId)
Deprecated.Policy ID of the Thing is now typed. UsesetPolicyId(PolicyId)
instead.Sets the given Policy ID to this builder.- Parameters:
policyId
- the Policy ID to set.- Returns:
- this builder to allow method chaining.
-
setPolicyId
ThingBuilder.FromScratch setPolicyId(@Nullable org.eclipse.ditto.model.policies.PolicyId policyId)
Sets the given Policy ID to this builder.- Parameters:
policyId
- the Policy ID to set.- Returns:
- this builder to allow method chaining.
-
removePolicyId
ThingBuilder.FromScratch removePolicyId()
Removes the Policy ID from this builder.- Returns:
- this builder to allow method chaining.
-
setAttributes
ThingBuilder.FromScratch setAttributes(Attributes attributes)
Sets the given attributes to this builder.- Parameters:
attributes
- the attributes to be set.- Returns:
- this builder to allow method chaining.
- Throws:
NullPointerException
- ifattributes
isnull
.
-
setAttributes
ThingBuilder.FromScratch setAttributes(org.eclipse.ditto.json.JsonObject attributesJsonObject)
Sets the attributes to this builder. The attributes are parsed from the given JSON object representation ofAttributes
.- Parameters:
attributesJsonObject
- the JSON object representation of the attributes to be set.- Returns:
- this builder to allow method chaining.
- Throws:
NullPointerException
- ifattributesJsonObject
isnull
.
-
setAttributes
ThingBuilder.FromScratch setAttributes(String attributesJsonString)
Sets the attributes to this builder. The attributes are parsed from the given JSON string representation ofAttributes
.- Parameters:
attributesJsonString
- JSON string representation of the attributes to be set.- Returns:
- this builder to allow method chaining.
- Throws:
org.eclipse.ditto.model.base.exceptions.DittoJsonException
- ifattributesJsonString
is not a valid JSON object.
-
removeAllAttributes
ThingBuilder.FromScratch removeAllAttributes()
Removes all attributes from this builder.- Returns:
- this builder to allow method chaining.
-
setEmptyAttributes
ThingBuilder.FromScratch setEmptyAttributes()
Sets empty attributes to this builder. All already set attributes are discarded.- Returns:
- this builder to allow method chaining.
-
setNullAttributes
ThingBuilder.FromScratch setNullAttributes()
Sets attributes to this builder which represent semanticallynull
. All already set attributes are discarded.- Returns:
- this builder to allow method chaining.
-
setAttribute
ThingBuilder.FromScratch setAttribute(org.eclipse.ditto.json.JsonPointer attributePath, org.eclipse.ditto.json.JsonValue attributeValue)
Sets the given attribute to this builder.- Parameters:
attributePath
- the hierarchical path to the attribute value.attributeValue
- the value to be set.- Returns:
- this builder to allow method chaining.
- Throws:
NullPointerException
- if any argument isnull
.IllegalArgumentException
- ifattributePath
is empty.
-
removeAttribute
ThingBuilder.FromScratch removeAttribute(org.eclipse.ditto.json.JsonPointer attributePath)
Removes the attribute at the given path from this builder.- Parameters:
attributePath
- the hierarchical path to the attribute to be removed.- Returns:
- this builder to allow method chaining.
- Throws:
NullPointerException
- if attributes were set already andattributePath
isnull
.
-
setDefinition
ThingBuilder.FromScratch setDefinition(@Nullable ThingDefinition definition)
Sets the given ThingDefinition to this builder.- Parameters:
definition
- the Definition to set.- Returns:
- this builder to allow method chaining.
-
setNullDefinition
ThingBuilder.FromScratch setNullDefinition()
Sets the ThingDefinition to this builder which represent semanticallynull
. An already set definition is discarded.- Returns:
- this builder to allow method chaining.
-
removeDefinition
ThingBuilder.FromScratch removeDefinition()
Removes the Definition from this builder.- Returns:
- this builder to allow method chaining.
-
setFeature
ThingBuilder.FromScratch setFeature(Feature feature)
Sets the given Feature to this builder. A previously set Feature with the same ID is replaced.- Parameters:
feature
- the Feature to be set.- Returns:
- this builder to allow method chaining.
- Throws:
NullPointerException
- iffeature
isnull
.
-
setFeature
ThingBuilder.FromScratch setFeature(String featureId)
Sets a Feature with the given ID to this builder. A previously set Feature with the same ID is replaced.- Parameters:
featureId
- the identifier of the Feature to be set.- Returns:
- this builder to allow method chaining.
- Throws:
NullPointerException
- iffeatureId
isnull
.
-
setFeature
ThingBuilder.FromScratch setFeature(String featureId, FeatureDefinition featureDefinition, FeatureProperties featureProperties)
Sets a Feature with the given ID and properties to this builder. A previously set Feature with the same ID is replaced.- Parameters:
featureId
- the ID of the Feature to be set.featureDefinition
- the definition of the Feature to be set.featureProperties
- the properties of the Feature to be set.- Returns:
- this builder to allow method chaining.
- Throws:
NullPointerException
- iffeatureId
isnull
.
-
setFeature
ThingBuilder.FromScratch setFeature(String featureId, FeatureProperties featureProperties)
Sets a Feature with the given ID and properties to this builder. A previously set Feature with the same ID is replaced.- Parameters:
featureId
- the ID of the Feature to be set.featureProperties
- the properties of the Feature to be set.- Returns:
- this builder to allow method chaining.
- Throws:
NullPointerException
- iffeatureId
isnull
.
-
removeFeature
ThingBuilder.FromScratch removeFeature(String featureId)
Removes the Feature with the given ID from this builder. If this was the last Feature the Thing will not have features.- Parameters:
featureId
- the ID of the Feature to be removed.- Returns:
- this builder to allow method chaining.
- Throws:
NullPointerException
- iffeatureId
isnull
.
-
setFeatureDefinition
ThingBuilder.FromScratch setFeatureDefinition(String featureId, FeatureDefinition featureDefinition)
Sets the given definition to the Feature with the given ID on this builder. If this builder does not yet know a Feature with the given ID it creates one.- Parameters:
featureId
- the ID of the Feature to be set.featureDefinition
- the definition of the Feature to be set.- Returns:
- this builder to allow method chaining.
- Throws:
NullPointerException
- if any argument isnull
.
-
removeFeatureDefinition
ThingBuilder.FromScratch removeFeatureDefinition(String featureId)
Removes the definition from Feature with the given identifier on this builder.- Parameters:
featureId
- the ID of the Feature from which the definition is to be deleted.- Returns:
- this builder to allow method chaining.
- Throws:
NullPointerException
- iffeatureId
isnull
.
-
setFeatureProperty
ThingBuilder.FromScratch setFeatureProperty(String featureId, org.eclipse.ditto.json.JsonPointer propertyPath, org.eclipse.ditto.json.JsonValue propertyValue)
Sets the given property to the Feature with the given ID on this builder.- Parameters:
featureId
- the ID of the Feature.propertyPath
- the hierarchical path within the Feature to the property to be set.propertyValue
- the property value to be set.- Returns:
- this builder to allow method chaining.
- Throws:
NullPointerException
- if any argument isnull
.
-
removeFeatureProperty
ThingBuilder.FromScratch removeFeatureProperty(String featureId, org.eclipse.ditto.json.JsonPointer propertyPath)
Removes the given property from the Feature with the given ID on this builder.- Parameters:
featureId
- the ID of the Feature.propertyPath
- the hierarchical path to within the Feature to the property to be removed.- Returns:
- this builder to allow method chaining.
- Throws:
NullPointerException
- if any argument isnull
.
-
setFeatureProperties
ThingBuilder.FromScratch setFeatureProperties(String featureId, FeatureProperties featureProperties)
Sets the given properties to the Feature with the given ID on this builder.- Parameters:
featureId
- the ID of the Feature.featureProperties
- the properties to be set.- Returns:
- this builder to allow method chaining.
- Throws:
NullPointerException
- if any argument isnull
.
-
removeFeatureProperties
ThingBuilder.FromScratch removeFeatureProperties(String featureId)
Removes all properties from the Feature with the given ID on this builder.- Parameters:
featureId
- the ID of the Feature.- Returns:
- this builder to allow method chaining.
- Throws:
NullPointerException
- iffeatureId
isnull
.
-
setFeatures
ThingBuilder.FromScratch setFeatures(org.eclipse.ditto.json.JsonObject featuresJsonObject)
Sets the features to this builder. The features are parsed from the given JSON object representation ofFeatures
.- Parameters:
featuresJsonObject
- JSON object representation of the features to be set.- Returns:
- this builder to allow method chaining.
- Throws:
NullPointerException
- iffeaturesJsonObject
isnull
.org.eclipse.ditto.model.base.exceptions.DittoJsonException
- iffeaturesJsonObject
cannot be parsed toFeatures
.
-
setFeatures
ThingBuilder.FromScratch setFeatures(String featuresJsonString)
Sets the Features of the Thing based on the given JSON object.- Parameters:
featuresJsonString
- JSON string providing the Features of the Thing.- Returns:
- this builder to allow method chaining.
- Throws:
org.eclipse.ditto.model.base.exceptions.DittoJsonException
- iffeaturesJsonString
cannot be parsed toFeatures
.
-
setFeatures
ThingBuilder.FromScratch setFeatures(Iterable<Feature> features)
Sets the given Features to this builder.- Parameters:
features
- the Features to be set.- Returns:
- this builder to allow method chaining.
- Throws:
NullPointerException
- iffeatures
isnull
.
-
removeAllFeatures
ThingBuilder.FromScratch removeAllFeatures()
Removes all features from this builder.- Returns:
- this builder to allow method chaining.
-
setEmptyFeatures
ThingBuilder.FromScratch setEmptyFeatures()
Sets empty features to this builder. All already set features are discarded.- Returns:
- this builder to allow method chaining.
-
setNullFeatures
ThingBuilder.FromScratch setNullFeatures()
Sets features to this builder which represents semanticallynull
. All already set features are discarded.- Returns:
- this builder to allow method chaining.
-
setLifecycle
ThingBuilder.FromScratch setLifecycle(ThingLifecycle lifecycle)
Sets the given lifecycle to this builder.- Parameters:
lifecycle
- the lifecycle to be set.- Returns:
- this builder to allow method chaining.
-
setRevision
ThingBuilder.FromScratch setRevision(ThingRevision revision)
Sets the given revision to this builder.- Parameters:
revision
- the revision to be set.- Returns:
- this builder to allow method chaining.
-
setRevision
ThingBuilder.FromScratch setRevision(long revisionNumber)
Sets the given revision number to this builder.- Parameters:
revisionNumber
- the revision number to be set.- Returns:
- this builder to allow method chaining.
-
setModified
ThingBuilder.FromScratch setModified(@Nullable Instant modified)
Sets the given modified to this builder.- Parameters:
modified
- the modified to be set.- Returns:
- this builder to allow method chaining.
-
setId
@Deprecated default ThingBuilder.FromScratch setId(@Nullable String thingId)
Deprecated.thing ID is now typed. UsesetId(ThingId)
instead.Sets the given Thing ID to this builder. The ID is required to include the Thing's namespace.- Parameters:
thingId
- the Thing ID to be set.- Returns:
- this builder to allow method chaining.
- Throws:
ThingIdInvalidException
- ifthingId
does not comply to the required pattern.
-
setId
ThingBuilder.FromScratch setId(@Nullable ThingId thingId)
Sets the given Thing ID to this builder. The ID is required to include the Thing's namespace.- Parameters:
thingId
- the Thing ID to be set.- Returns:
- this builder to allow method chaining.
-
setGeneratedId
ThingBuilder.FromScratch setGeneratedId()
Sets a generated Thing ID to this builder.- Returns:
- this builder to allow method chaining.
-
-