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 Details

    • setPolicyId

      ThingBuilder.FromScratch setPolicyId(@Nullable org.eclipse.ditto.policies.model.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 - if attributes is null.
    • 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 of Attributes.
      Parameters:
      attributesJsonObject - the JSON object representation of the attributes to be set.
      Returns:
      this builder to allow method chaining.
      Throws:
      NullPointerException - if attributesJsonObject is null.
    • setAttributes

      ThingBuilder.FromScratch setAttributes(String attributesJsonString)
      Sets the attributes to this builder. The attributes are parsed from the given JSON string representation of Attributes.
      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 - if attributesJsonString 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 semantically null. 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 is null.
      IllegalArgumentException - if attributePath 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 and attributePath is null.
    • 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 semantically null. 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 - if feature is null.
    • 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 - if featureId is null.
    • 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 - if featureId is null.
    • 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 - if featureId is null.
      Since:
      1.5.0
    • 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 - if featureId is null.
    • 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 - if featureId is null.
    • 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 is null.
    • 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 - if featureId is null.
    • 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 is null.
    • 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 is null.
    • 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 is null.
    • 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 - if featureId is null.
    • 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 is null.
      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 is null.
      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 is null.
      Since:
      1.5.0
    • removeFeatureDesiredProperties

      ThingBuilder.FromScratch removeFeatureDesiredProperties(CharSequence featureId)
      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 - if featureId is null.
      Since:
      1.5.0
    • 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 of Features.
      Parameters:
      featuresJsonObject - JSON object representation of the features to be set.
      Returns:
      this builder to allow method chaining.
      Throws:
      NullPointerException - if featuresJsonObject is null.
      org.eclipse.ditto.base.model.exceptions.DittoJsonException - if featuresJsonObject cannot be parsed to Features.
    • 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.base.model.exceptions.DittoJsonException - if featuresJsonString cannot be parsed to Features.
    • 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 - if features is null.
    • 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 semantically null. 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 timestamp to this builder.
      Parameters:
      modified - the modified timestamp to be set.
      Returns:
      this builder to allow method chaining.
    • setCreated

      ThingBuilder.FromScratch setCreated(@Nullable Instant created)
      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

      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.
    • build

      Thing build()
      Creates a new immutable Thing containing all properties which were set to this builder beforehand.
      Returns:
      the new Thing.