Package org.eclipse.ditto.things.model
Interface ThingBuilder.FromScratch
- Enclosing interface:
- ThingBuilder
@NotThreadSafe
public static interface ThingBuilder.FromScratch
A mutable builder with a fluent API for an immutable
Thing from scratch.-
Method Summary
Modifier and TypeMethodDescriptionbuild()Creates a new immutableThingcontaining all properties which were set to this builder beforehand.Removes all attributes from this builder.Removes all features from this builder.removeAttribute(org.eclipse.ditto.json.JsonPointer attributePath) Removes the attribute at the given path from this builder.Removes the Definition from this builder.removeFeature(String featureId) Removes the Feature with the given ID from this builder.removeFeatureDefinition(String featureId) Removes the definition from Feature with the given identifier on this builder.removeFeatureDesiredProperties(CharSequence featureId) Removes all desired properties from the Feature with the given ID on this builder.removeFeatureDesiredProperty(CharSequence featureId, org.eclipse.ditto.json.JsonPointer desiredPropertyPath) Removes the given desired property from the Feature with the given ID on this builder.removeFeatureProperties(String featureId) Removes all properties from the Feature with the given ID on this builder.removeFeatureProperty(String featureId, org.eclipse.ditto.json.JsonPointer propertyPath) Removes the given property from the Feature with the given ID on this builder.Removes the Policy ID from this builder.setAttribute(org.eclipse.ditto.json.JsonPointer attributePath, org.eclipse.ditto.json.JsonValue attributeValue) Sets the given attribute to this builder.setAttributes(String attributesJsonString) Sets the attributes to this builder.setAttributes(org.eclipse.ditto.json.JsonObject attributesJsonObject) Sets the attributes to this builder.setAttributes(Attributes attributes) Sets the given attributes to this builder.setCreated(Instant created) Sets the given created timestamp to this builder.setDefinition(ThingDefinition definition) Sets the given ThingDefinition to this builder.Sets empty attributes to this builder.Sets empty features to this builder.setFeature(CharSequence featureId, FeatureDefinition featureDefinition, FeatureProperties featureProperties, FeatureProperties featureDesiredProperties) Sets a Feature with the given ID and properties to this builder.setFeature(String featureId) Sets a Feature with the given ID to this builder.setFeature(String featureId, FeatureDefinition featureDefinition, FeatureProperties featureProperties) Sets a Feature with the given ID and properties to this builder.setFeature(String featureId, FeatureProperties featureProperties) Sets a Feature with the given ID and properties to this builder.setFeature(Feature feature) Sets the given Feature to this builder.setFeatureDefinition(String featureId, FeatureDefinition featureDefinition) Sets the given definition to the Feature with the given ID on this builder.setFeatureDesiredProperties(CharSequence featureId, FeatureProperties desiredFeatureProperties) Sets the given desired properties to the Feature with the given ID on this builder.setFeatureDesiredProperty(CharSequence featureId, org.eclipse.ditto.json.JsonPointer desiredPropertyPath, org.eclipse.ditto.json.JsonValue desiredPropertyValue) Sets the given desired property to the Feature with the given ID on this builder.setFeatureProperties(String featureId, FeatureProperties featureProperties) Sets the given properties to the Feature with the given ID on this builder.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.setFeatures(Iterable<Feature> features) Sets the given Features to this builder.setFeatures(String featuresJsonString) Sets the Features of the Thing based on the given JSON object.setFeatures(org.eclipse.ditto.json.JsonObject featuresJsonObject) Sets the features to this builder.Sets a generated Thing ID to this builder.Sets the given Thing ID to this builder.setLifecycle(ThingLifecycle lifecycle) Sets the given lifecycle to this builder.setMetadata(org.eclipse.ditto.base.model.entity.metadata.Metadata metadata) Sets the given Metadata to this builder.setModified(Instant modified) Sets the given modified timestamp to this builder.Sets attributes to this builder which represent semanticallynull.Sets the ThingDefinition to this builder which represent semanticallynull.Sets features to this builder which represents semanticallynull.setPolicyId(org.eclipse.ditto.policies.model.PolicyId policyId) Sets the given Policy ID to this builder.setRevision(long revisionNumber) Sets the given revision number to this builder.setRevision(ThingRevision revision) Sets the given revision to this builder.
-
Method Details
-
setPolicyId
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
Sets the given attributes to this builder.- Parameters:
attributes- the attributes to be set.- Returns:
- this builder to allow method chaining.
- Throws:
NullPointerException- ifattributesisnull.
-
setAttributes
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- ifattributesJsonObjectisnull.
-
setAttributes
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.base.model.exceptions.DittoJsonException- ifattributesJsonStringis 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- ifattributePathis empty.
-
removeAttribute
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 andattributePathisnull.
-
setDefinition
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
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- iffeatureisnull.
-
setFeature
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- iffeatureIdisnull.
-
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- iffeatureIdisnull.
-
setFeature
ThingBuilder.FromScratch setFeature(CharSequence featureId, @Nullable FeatureDefinition featureDefinition, @Nullable FeatureProperties featureProperties, @Nullable FeatureProperties featureDesiredProperties) 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.featureDesiredProperties- the desired properties of the Feature to be set.- Returns:
- this builder to allow method chaining.
- Throws:
NullPointerException- iffeatureIdisnull.- Since:
- 1.5.0
-
setFeature
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- iffeatureIdisnull.
-
removeFeature
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- iffeatureIdisnull.
-
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
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- iffeatureIdisnull.
-
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
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- iffeatureIdisnull.
-
setFeatureDesiredProperty
ThingBuilder.FromScratch setFeatureDesiredProperty(CharSequence featureId, org.eclipse.ditto.json.JsonPointer desiredPropertyPath, org.eclipse.ditto.json.JsonValue desiredPropertyValue) Sets the given desired property to the Feature with the given ID on this builder.- Parameters:
featureId- the ID of the Feature.desiredPropertyPath- the hierarchical path within the Feature to the desired property to be set.desiredPropertyValue- the desired property value to be set.- Returns:
- this builder to allow method chaining.
- Throws:
NullPointerException- if any argument isnull.- Since:
- 1.5.0
-
removeFeatureDesiredProperty
ThingBuilder.FromScratch removeFeatureDesiredProperty(CharSequence featureId, org.eclipse.ditto.json.JsonPointer desiredPropertyPath) Removes the given desired property from the Feature with the given ID on this builder.- Parameters:
featureId- the ID of the Feature.desiredPropertyPath- the hierarchical path to within the Feature to the desired property to be removed.- Returns:
- this builder to allow method chaining.
- Throws:
NullPointerException- if any argument isnull.- Since:
- 1.5.0
-
setFeatureDesiredProperties
ThingBuilder.FromScratch setFeatureDesiredProperties(CharSequence featureId, FeatureProperties desiredFeatureProperties) Sets the given desired properties to the Feature with the given ID on this builder.- Parameters:
featureId- the ID of the Feature.desiredFeatureProperties- the desired properties to be set.- Returns:
- this builder to allow method chaining.
- Throws:
NullPointerException- if any argument isnull.- Since:
- 1.5.0
-
removeFeatureDesiredProperties
Removes all desired 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- iffeatureIdisnull.- Since:
- 1.5.0
-
setFeatures
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- iffeaturesJsonObjectisnull.org.eclipse.ditto.base.model.exceptions.DittoJsonException- iffeaturesJsonObjectcannot be parsed toFeatures.
-
setFeatures
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.base.model.exceptions.DittoJsonException- iffeaturesJsonStringcannot be parsed toFeatures.
-
setFeatures
Sets the given Features to this builder.- Parameters:
features- the Features to be set.- Returns:
- this builder to allow method chaining.
- Throws:
NullPointerException- iffeaturesisnull.
-
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
Sets the given lifecycle to this builder.- Parameters:
lifecycle- the lifecycle to be set.- Returns:
- this builder to allow method chaining.
-
setRevision
Sets the given revision to this builder.- Parameters:
revision- the revision to be set.- Returns:
- this builder to allow method chaining.
-
setRevision
Sets the given revision number to this builder.- Parameters:
revisionNumber- the revision number to be set.- Returns:
- this builder to allow method chaining.
-
setModified
Sets the given modified timestamp to this builder.- Parameters:
modified- the modified timestamp to be set.- Returns:
- this builder to allow method chaining.
-
setCreated
Sets the given created timestamp to this builder.- Parameters:
created- the created timestamp to be set.- Returns:
- this builder to allow method chaining.
- Since:
- 1.2.0
-
setMetadata
ThingBuilder.FromScratch setMetadata(@Nullable org.eclipse.ditto.base.model.entity.metadata.Metadata metadata) Sets the given Metadata to this builder.- Parameters:
metadata- the metadata to be set.- Returns:
- this builder to allow method chaining.
- Since:
- 1.2.0
-
setId
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.
-
build
Thing build()Creates a new immutableThingcontaining all properties which were set to this builder beforehand.- Returns:
- the new Thing.
-