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 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 is null.
      • 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 is null.
      • 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 - if aclEntries is null.
      • 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 - if accessControlListJsonObject is null.
        org.eclipse.ditto.model.base.exceptions.DittoJsonException - if accessControlListJsonObject cannot be parsed to AccessControlList.
      • 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 - if accessControlListJsonString cannot be parsed to AccessControlList.
        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 is null.
      • 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 - if authorizationSubject is null.
      • 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

        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 - 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.model.base.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​(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.
      • 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.model.base.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.model.base.exceptions.DittoJsonException - if featuresJsonString cannot be parsed to Features.
      • 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 to this builder.
        Parameters:
        modified - the modified to be set.
        Returns:
        this builder to allow method chaining.
      • 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.