Class ThingsModelFactory


  • @Immutable
    public final class ThingsModelFactory
    extends java.lang.Object
    Factory that creates new things objects.
    • Method Detail

      • emptyAttributes

        public static Attributes emptyAttributes()
        Returns a new immutable empty Attributes.
        Returns:
        the new immutable empty Attributes.
      • nullAttributes

        public static Attributes nullAttributes()
        Returns a new immutable Attributes which represents null.
        Returns:
        the new null-like Attributes.
      • newAttributes

        public static Attributes newAttributes​(org.eclipse.ditto.json.JsonObject jsonObject)
        Returns a new immutable Attributes which is initialised with the values of the given JSON object.
        Parameters:
        jsonObject - provides the initial values of the result.
        Returns:
        the new immutable initialised Attributes.
        Throws:
        java.lang.NullPointerException - if jsonObject is null.
      • newAttributes

        public static Attributes newAttributes​(java.lang.String jsonString)
        Returns a new immutable Attributes which is initialised with the values of the given JSON string. This string is required to be a valid JsonObject.
        Parameters:
        jsonString - provides the initial values of the result;
        Returns:
        the new immutable initialised Attributes.
        Throws:
        org.eclipse.ditto.base.model.exceptions.DittoJsonException - if jsonString cannot be parsed to Attributes.
      • newAttributesBuilder

        public static AttributesBuilder newAttributesBuilder()
        Returns a new empty builder for a Attributes.
        Returns:
        the builder.
      • newAttributesBuilder

        public static AttributesBuilder newAttributesBuilder​(org.eclipse.ditto.json.JsonObject jsonObject)
        Returns a new builder for a Attributes which is initialised with the values of the given JSON object.
        Parameters:
        jsonObject - provides the initial values of the result.
        Returns:
        the builder.
        Throws:
        java.lang.NullPointerException - if jsonObject is null.
      • newDefinition

        public static ThingDefinition newDefinition​(@Nullable
                                                    java.lang.CharSequence thingDefinition)
        Returns a new immutable ThingDefinition which is initialised with the parsed thingDefinition.
        Parameters:
        thingDefinition - Definition identifier which should be parsed as ThingDefinition.
        Returns:
        new ThingDefinition with the parsed definition identifier.
      • nullDefinition

        public static ThingDefinition nullDefinition()
        Returns a new immutable ThingDefinition which represents null.
        Returns:
        the new null-like ThingDefinition.
      • newFeatureDefinitionIdentifier

        public static DefinitionIdentifier newFeatureDefinitionIdentifier​(java.lang.CharSequence namespace,
                                                                          java.lang.CharSequence name,
                                                                          java.lang.CharSequence version)
        Returns an immutable instance of DefinitionIdentifier.
        Parameters:
        namespace - the namespace of the returned Identifier.
        name - the name of the returned Identifier.
        version - the version of the returned Identifier.
        Returns:
        the instance.
        Throws:
        java.lang.NullPointerException - if any argument is null.
        java.lang.IllegalArgumentException - if any argument is empty.
      • newFeatureDefinitionIdentifier

        public static DefinitionIdentifier newFeatureDefinitionIdentifier​(java.lang.CharSequence featureIdentifierAsCharSequence)
        Parses the specified CharSequence and returns an immutable instance of DefinitionIdentifier.
        Parameters:
        featureIdentifierAsCharSequence - CharSequence-representation of a FeatureDefinition Identifier.
        Returns:
        the instance.
        Throws:
        java.lang.NullPointerException - if featureIdentifierAsCharSequence is null.
        DefinitionIdentifierInvalidException - if featureIdentifierAsCharSequence is invalid.
      • newFeatureDefinition

        public static FeatureDefinition newFeatureDefinition​(org.eclipse.ditto.json.JsonArray jsonArray)
        Parses the specified JsonArray and returns an immutable instance of FeatureDefinition which is initialised with the values of the given JSON array.
        Parameters:
        jsonArray - JSON array containing the identifiers of the FeatureDefinition to be returned. Non-string values are ignored.
        Returns:
        the instance.
        Throws:
        java.lang.NullPointerException - if jsonArray is null.
        FeatureDefinitionEmptyException - if jsonArray is empty.
        DefinitionIdentifierInvalidException - if any Identifier string of the array is invalid.
      • newFeatureDefinition

        public static FeatureDefinition newFeatureDefinition​(java.lang.String jsonString)
        Returns a new immutable FeatureDefinition which is initialised with the values of the given JSON string. This string is required to be a valid JsonArray.
        Parameters:
        jsonString - provides the initial values of the result;
        Returns:
        the new immutable initialised FeatureDefinition.
        Throws:
        org.eclipse.ditto.base.model.exceptions.DittoJsonException - if jsonString cannot be parsed to FeatureDefinition.
        FeatureDefinitionEmptyException - if the JSON array is empty.
        DefinitionIdentifierInvalidException - if any Identifier of the JSON array is invalid.
      • nullFeatureDefinition

        public static FeatureDefinition nullFeatureDefinition()
        Returns a new immutable FeatureDefinition which represents null.
        Returns:
        the new null-like FeatureDefinition.
      • newFeatureDefinitionBuilder

        public static FeatureDefinitionBuilder newFeatureDefinitionBuilder​(java.lang.CharSequence firstIdentifier)
        Parses the specified CharSequence and returns a mutable builder with a fluent API for an immutable FeatureDefinition. The returned builder is initialised with the parsed Identifier as its first one.
        Parameters:
        firstIdentifier - CharSequence-representation of the first FeatureDefinition Identifier.
        Returns:
        the instance.
        Throws:
        java.lang.NullPointerException - if firstIdentifier is null.
        DefinitionIdentifierInvalidException - if firstIdentifier is invalid.
      • newFeatureDefinitionBuilder

        public static FeatureDefinitionBuilder newFeatureDefinitionBuilder​(org.eclipse.ditto.json.JsonArray jsonArray)
        Returns a new builder for an immutable FeatureDefinition which is initialised with the values of the given JSON array.
        Parameters:
        jsonArray - provides the initial values of the result.
        Returns:
        the builder.
        Throws:
        java.lang.NullPointerException - if jsonArray is null.
        DefinitionIdentifierInvalidException - if any Identifier of the array is invalid.
      • emptyFeatureProperties

        public static FeatureProperties emptyFeatureProperties()
        Returns a new immutable empty FeatureProperties.
        Returns:
        the new immutable empty FeatureProperties.
      • nullFeatureProperties

        public static FeatureProperties nullFeatureProperties()
        Returns a new immutable FeatureProperties which represents null.
        Returns:
        the new null-like FeatureProperties.
      • newFeatureProperties

        public static FeatureProperties newFeatureProperties​(org.eclipse.ditto.json.JsonObject jsonObject)
        Returns a new immutable FeatureProperties which is initialised with the values of the given JSON object.
        Parameters:
        jsonObject - provides the initial values of the result.
        Returns:
        the new immutable initialised FeatureProperties.
        Throws:
        java.lang.NullPointerException - if jsonObject is null.
        org.eclipse.ditto.json.JsonKeyInvalidException - if a property name in the passed jsonObject was not valid according to pattern RegexPatterns.NO_CONTROL_CHARS_NO_SLASHES_PATTERN.
      • newFeatureProperties

        public static FeatureProperties newFeatureProperties​(java.lang.String jsonString)
        Returns a new immutable FeatureProperties which is initialised with the values of the given JSON string. This string is required to be a valid JsonObject.
        Parameters:
        jsonString - provides the initial values of the result;
        Returns:
        the new immutable initialised FeatureProperties.
        Throws:
        org.eclipse.ditto.base.model.exceptions.DittoJsonException - if jsonString cannot be parsed to FeatureProperties.
      • newFeaturePropertiesBuilder

        public static FeaturePropertiesBuilder newFeaturePropertiesBuilder​(org.eclipse.ditto.json.JsonObject jsonObject)
        Returns a new builder for an immutable FeatureProperties which is initialised with the values of the given JSON object.
        Parameters:
        jsonObject - provides the initial values of the result.
        Returns:
        the builder.
        Throws:
        java.lang.NullPointerException - if jsonObject is null.
      • nullFeature

        public static Feature nullFeature​(java.lang.String featureId)
        Returns a new immutable Feature which represents null.
        Parameters:
        featureId - the ID of the new Feature.
        Returns:
        the new null-like Feature.
        Throws:
        java.lang.NullPointerException - if featureId is null.
        org.eclipse.ditto.json.JsonKeyInvalidException - if featureId was not valid according to pattern RegexPatterns.NO_CONTROL_CHARS_NO_SLASHES_PATTERN.
      • newFeature

        public static Feature newFeature​(java.lang.String featureId)
        Returns a new immutable Feature with the given ID.
        Parameters:
        featureId - the ID of the new Feature.
        Returns:
        the new immutable Feature.
        Throws:
        java.lang.NullPointerException - if featureId is null.
        org.eclipse.ditto.json.JsonKeyInvalidException - if featureId was not valid according to pattern RegexPatterns.NO_CONTROL_CHARS_NO_SLASHES_PATTERN.
      • newFeature

        public static Feature newFeature​(java.lang.String featureId,
                                         @Nullable
                                         FeatureProperties featureProperties)
        Returns a new immutable Feature with the given ID and properties.
        Parameters:
        featureId - the ID of the new feature.
        featureProperties - the properties of the new Feature or null.
        Returns:
        the new immutable Feature.
        Throws:
        java.lang.NullPointerException - if featureId is null.
        org.eclipse.ditto.json.JsonKeyInvalidException - if featureId was not valid according to pattern RegexPatterns.NO_CONTROL_CHARS_NO_SLASHES_PATTERN.
      • newFeature

        public static Feature newFeature​(java.lang.String featureId,
                                         @Nullable
                                         FeatureDefinition featureDefinition)
        Returns a new immutable Feature with the given ID, properties and Definition.
        Parameters:
        featureId - the ID of the new feature.
        featureDefinition - the Definition of the new Feature or null.
        Returns:
        the new immutable Feature.
        Throws:
        java.lang.NullPointerException - if featureId is null.
        org.eclipse.ditto.json.JsonKeyInvalidException - if featureId was not valid according to pattern RegexPatterns.NO_CONTROL_CHARS_NO_SLASHES_PATTERN.
      • newFeature

        public static Feature newFeature​(java.lang.String featureId,
                                         @Nullable
                                         FeatureDefinition featureDefinition,
                                         @Nullable
                                         FeatureProperties featureProperties)
        Returns a new immutable Feature with the given ID, properties and Definition.
        Parameters:
        featureId - the ID of the new feature.
        featureDefinition - the Definition of the new Feature or null.
        featureProperties - the properties of the new Feature or null.
        Returns:
        the new immutable Feature.
        Throws:
        java.lang.NullPointerException - if featureId is null.
        org.eclipse.ditto.json.JsonKeyInvalidException - if featureId was not valid according to pattern RegexPatterns.NO_CONTROL_CHARS_NO_SLASHES_PATTERN.
      • newFeature

        public static Feature newFeature​(java.lang.CharSequence featureId,
                                         @Nullable
                                         FeatureDefinition featureDefinition,
                                         @Nullable
                                         FeatureProperties featureProperties,
                                         @Nullable
                                         FeatureProperties desiredFeatureProperties)
        Returns a new immutable Feature with the given ID, properties, desired Properties and Definition.
        Parameters:
        featureId - the ID of the new feature.
        featureDefinition - the Definition of the new Feature or null.
        featureProperties - the properties of the new Feature or null.
        desiredFeatureProperties - the desired properties of the new Feature or null.
        Returns:
        the new immutable Feature.
        Throws:
        java.lang.NullPointerException - if featureId is null.
        org.eclipse.ditto.json.JsonKeyInvalidException - if featureId was not valid according to pattern RegexPatterns.NO_CONTROL_CHARS_NO_SLASHES_PATTERN.
        Since:
        1.5.0
      • newFeatureBuilder

        public static FeatureBuilder.FromCopyBuildable newFeatureBuilder​(Feature feature)
        Returns a new builder for an immutable Feature which is initialised with the values of the given Feature.
        Parameters:
        feature - provides the initial values for the result.
        Returns:
        the builder.
        Throws:
        java.lang.NullPointerException - if feature is null.
      • newFeatureBuilder

        public static FeatureBuilder.FromJsonBuildable newFeatureBuilder​(org.eclipse.ditto.json.JsonObject jsonObject)
        Returns a new builder for an immutable Feature which is initialised with the values of the given JSON object.
        Parameters:
        jsonObject - provides the initial values for the result.
        Returns:
        the builder.
        Throws:
        java.lang.NullPointerException - if jsonObject is null.
      • newFeatureBuilder

        public static FeatureBuilder.FromJsonBuildable newFeatureBuilder​(java.lang.String jsonString)
        Returns a new builder for an immutable Feature which is initialised with the values of the given JSON string. The JSON string is parsed in a fault tolerant way. I. e. all properties which cannot be deserialized are supposed to not exist.
        Parameters:
        jsonString - string the JSON string representation of a Feature.
        Returns:
        the builder.
        Throws:
        org.eclipse.ditto.base.model.exceptions.DittoJsonException - if jsonString cannot be parsed to Feature.
        See Also:
        newFeatureBuilder(JsonObject)
      • emptyFeatures

        public static Features emptyFeatures()
        Returns a new immutable empty Features.
        Returns:
        the new immutable empty Features.
      • nullFeatures

        public static Features nullFeatures()
        Returns a new immutable Features which represents null.
        Returns:
        the new null-like Features.
      • newFeatures

        public static Features newFeatures​(java.lang.Iterable<Feature> features)
        Returns a new immutable Features which is initialised with the features of the given Iterable.
        Parameters:
        features - the features to initialise the result with.
        Returns:
        the new immutable Features which is initialised with features.
        Throws:
        java.lang.NullPointerException - if features is null.
      • newFeatures

        public static Features newFeatures​(org.eclipse.ditto.json.JsonObject jsonObject)
        Returns a new immutable Features based on the given JSON object.
        Parameters:
        jsonObject - provides the initial values for the result.
        Returns:
        the new immutable Features which is initialised by the data of jsonObject.
        Throws:
        java.lang.NullPointerException - if jsonObject is null.
        org.eclipse.ditto.base.model.exceptions.DittoJsonException - if any JSON field which is supposed to represent a Feature is not a JSON object.
      • newFeatures

        public static Features newFeatures​(java.lang.String jsonString)
        Returns a new immutable Features based on the given JSON string.
        Parameters:
        jsonString - provides the initial values of the result.
        Returns:
        the new immutable initialised Features.
        Throws:
        org.eclipse.ditto.base.model.exceptions.DittoJsonException - if jsonString cannot be parsed to Features.
      • newFeatures

        public static Features newFeatures​(Feature feature,
                                           Feature... additionalFeatures)
        Returns a new immutable Features which is initialised with the given features.
        Parameters:
        feature - the initial Feature of the result.
        additionalFeatures - additional features of the result.
        Returns:
        the new immutable Features which is initialised with feature and potentially with additionalFeatures.
        Throws:
        java.lang.NullPointerException - if any argument is null.
      • newFeaturesBuilder

        public static FeaturesBuilder newFeaturesBuilder()
        Returns a new mutable builder with a fluent API for an immutable Features.
        Returns:
        the builder.
      • newFeaturesBuilder

        public static FeaturesBuilder newFeaturesBuilder​(java.lang.Iterable<Feature> features)
        Returns a new mutable builder with a fluent API for an immutable Features. The builder is initialised with the given features.
        Parameters:
        features - the initial features of the new builder.
        Returns:
        the builder.
        Throws:
        java.lang.NullPointerException - if features is null.
      • validateFeaturePropertyPointer

        public static org.eclipse.ditto.json.JsonPointer validateFeaturePropertyPointer​(org.eclipse.ditto.json.JsonPointer jsonPointer)
        Validates the given JsonPointer to a feature property.
        Parameters:
        jsonPointer - jsonPointer that is validated
        Returns:
        the same jsonPointer if validation was successful
        Throws:
        org.eclipse.ditto.json.JsonKeyInvalidException - if jsonPointer was not valid according to pattern RegexPatterns.NO_CONTROL_CHARS_NO_SLASHES_PATTERN.
        Since:
        1.2.0
      • validateJsonKeys

        public static void validateJsonKeys​(org.eclipse.ditto.json.JsonObject jsonObject)
        Validates the given JsonObject containing only valid keys.
        Parameters:
        jsonObject - jsonObject that is validated
        Throws:
        org.eclipse.ditto.json.JsonKeyInvalidException - if jsonObject was not valid according to pattern RegexPatterns.NO_CONTROL_CHARS_NO_SLASHES_PATTERN.
        Since:
        1.3.0
      • emptyMetadata

        public static org.eclipse.ditto.base.model.entity.metadata.Metadata emptyMetadata()
        Returns a new immutable empty Metadata.
        Returns:
        the new immutable empty Metadata.
        Since:
        1.2.0
      • nullMetadata

        public static org.eclipse.ditto.base.model.entity.metadata.Metadata nullMetadata()
        Returns a new immutable Metadata which represents null.
        Returns:
        the new null-like Metadata.
        Since:
        1.2.0
      • newMetadata

        public static org.eclipse.ditto.base.model.entity.metadata.Metadata newMetadata​(org.eclipse.ditto.json.JsonObject jsonObject)
        Returns a new immutable Metadata which is initialised with the values of the given JSON object.
        Parameters:
        jsonObject - provides the initial values of the result.
        Returns:
        the new immutable initialised Metadata.
        Throws:
        java.lang.NullPointerException - if jsonObject is null.
        Since:
        1.2.0
      • newMetadata

        public static org.eclipse.ditto.base.model.entity.metadata.Metadata newMetadata​(java.lang.String jsonString)
        Returns a new immutable Metadata which is initialised with the values of the given JSON string. This string is required to be a valid JsonObject.
        Parameters:
        jsonString - provides the initial values of the result;
        Returns:
        the new immutable initialised Metadata.
        Throws:
        org.eclipse.ditto.base.model.exceptions.DittoJsonException - if jsonString cannot be parsed to Metadata.
        Since:
        1.2.0
      • newMetadataBuilder

        public static org.eclipse.ditto.base.model.entity.metadata.MetadataBuilder newMetadataBuilder()
        Returns a new empty builder for a Metadata.
        Returns:
        the builder.
        Since:
        1.2.0
      • newMetadataBuilder

        public static org.eclipse.ditto.base.model.entity.metadata.MetadataBuilder newMetadataBuilder​(org.eclipse.ditto.base.model.entity.metadata.Metadata metadata)
        Returns a new builder for a Metadata which is initialised with the values of the given Metadata.
        Parameters:
        metadata - provides the initial values of the result.
        Returns:
        the builder.
        Throws:
        java.lang.NullPointerException - if metadata is null.
        Since:
        1.2.0
      • newThingRevision

        public static ThingRevision newThingRevision​(long revisionNumber)
        Returns a new immutable ThingRevision which is initialised with the given revision number.
        Parameters:
        revisionNumber - the long value of the revision.
        Returns:
        the new immutable ThingRevision.
      • newThing

        public static Thing newThing​(org.eclipse.ditto.json.JsonObject jsonObject)
        Returns a new immutable Thing based on the given JSON object.
        Parameters:
        jsonObject - the JSON object representation of a Thing.
        Returns:
        the new Thing.
        Throws:
        java.lang.NullPointerException - if jsonObject is null.
        org.eclipse.ditto.base.model.exceptions.DittoJsonException - if jsonObject cannot be parsed to Thing.
      • newThing

        public static Thing newThing​(java.lang.String jsonString)
        Returns a new immutable Thing based on the given JSON string.
        Parameters:
        jsonString - the JSON string representation of a Thing.
        Returns:
        the new Thing.
        Throws:
        java.lang.NullPointerException - if jsonString is null.
        org.eclipse.ditto.base.model.exceptions.DittoJsonException - if jsonString cannot be parsed to Thing.
      • newThingBuilder

        public static ThingBuilder.FromScratch newThingBuilder()
        Returns a mutable builder with a fluent API for an immutable Thing from scratch.
        Returns:
        the new builder.
      • newThingBuilder

        public static ThingBuilder.FromCopy newThingBuilder​(org.eclipse.ditto.json.JsonObject jsonObject)
        Returns a mutable builder with a fluent API for an immutable Thing based on the given JSON object. The JSON object is parsed in a fault tolerant way. I. e. all properties which cannot be deserialized are supposed to not exist.
        Parameters:
        jsonObject - the JSON object representation of a Thing.
        Returns:
        the new builder.
        Throws:
        java.lang.NullPointerException - if jsonObject is null.
        org.eclipse.ditto.base.model.exceptions.DittoJsonException - if jsonObject cannot be parsed to Thing.
      • newThingBuilder

        public static ThingBuilder.FromCopy newThingBuilder​(java.lang.String jsonString)
        Returns a mutable builder with a fluent API for an immutable Thing based on the given JSON string. The JSON string is parsed in a fault tolerant way. I. e. all properties which cannot be deserialized are supposed to not exist.
        Parameters:
        jsonString - string the JSON string representation of a Thing.
        Returns:
        the new builder.
        Throws:
        org.eclipse.ditto.base.model.exceptions.DittoJsonException - if jsonString cannot be parsed to Thing.
        See Also:
        newThingBuilder(JsonObject)
      • newThingBuilder

        public static ThingBuilder.FromCopy newThingBuilder​(Thing thing)
        Returns a mutable builder with a fluent API for an immutable Thing. The builder is initialised with the properties of the given Thing.
        Parameters:
        thing - the Thing which provides the initial properties of the builder.
        Returns:
        the new builder.
        Throws:
        java.lang.NullPointerException - if thing is null.