Class ThingsModelFactory

java.lang.Object
org.eclipse.ditto.things.model.ThingsModelFactory

@Immutable public final class ThingsModelFactory extends Object
Factory that creates new things objects.
  • Field Details

    • FEATURE_ID_WILDCARD

      public static final org.eclipse.ditto.json.JsonKey FEATURE_ID_WILDCARD
  • Method Details

    • 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:
      NullPointerException - if jsonObject is null.
    • newAttributes

      public static Attributes newAttributes(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:
      NullPointerException - if jsonObject is null.
    • newDefinition

      public static ThingDefinition newDefinition(@Nullable 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(CharSequence namespace, CharSequence name, 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:
      NullPointerException - if any argument is null.
      IllegalArgumentException - if any argument is empty.
    • newFeatureDefinitionIdentifier

      public static DefinitionIdentifier newFeatureDefinitionIdentifier(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:
      NullPointerException - if featureIdentifierAsCharSequence is null.
      DefinitionIdentifierInvalidException - if featureIdentifierAsCharSequence is invalid.
    • newFeatureDefinition

      public static FeatureDefinition newFeatureDefinition(Collection<DefinitionIdentifier> definitionIdentifiers)
      Creates a new instance of ImmutableFeatureDefinition based on the passed definitionIdentifiers.
      Parameters:
      definitionIdentifiers - the Identifiers of the FeatureDefinition to be returned.
      Returns:
      the instance.
      Throws:
      NullPointerException - if definitionIdentifiers is null.
      Since:
      3.0.0
    • 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:
      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(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(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:
      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:
      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:
      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(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()
      Returns a new empty builder for an immutable FeatureProperties.
      Returns:
      the builder.
    • 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:
      NullPointerException - if jsonObject is null.
    • nullFeature

      public static Feature nullFeature(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:
      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(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:
      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(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:
      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(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:
      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(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:
      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(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:
      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.FromScratchBuildable newFeatureBuilder()
      Returns a new builder for an immutable Feature from scratch with a fluent API.
      Returns:
      the builder.
    • 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:
      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:
      NullPointerException - if jsonObject is null.
    • newFeatureBuilder

      public static FeatureBuilder.FromJsonBuildable newFeatureBuilder(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:
    • 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(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:
      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:
      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(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:
      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(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:
      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:
      NullPointerException - if jsonObject is null.
      Since:
      1.2.0
    • newMetadata

      public static org.eclipse.ditto.base.model.entity.metadata.Metadata newMetadata(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:
      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:
      NullPointerException - if jsonObject is null.
      org.eclipse.ditto.base.model.exceptions.DittoJsonException - if jsonObject cannot be parsed to Thing.
    • newThing

      public static Thing newThing(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:
      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:
      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(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

      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:
      NullPointerException - if thing is null.
    • expandFeatureIdWildcards

      public static org.eclipse.ditto.json.JsonFieldSelector expandFeatureIdWildcards(Features features, org.eclipse.ditto.json.JsonFieldSelector jsonFieldSelector)
      Returns a new instance of JsonFieldSelector with expanded feature id wildcard.
      Returns:
      the new instance.
      Since:
      2.3.0
    • expandFeatureIdWildcards

      public static org.eclipse.ditto.json.JsonFieldSelector expandFeatureIdWildcards(Collection<org.eclipse.ditto.json.JsonKey> featureIds, org.eclipse.ditto.json.JsonFieldSelector jsonFieldSelector)
      Returns a new instance of JsonFieldSelector with expanded feature id wildcard.
      Returns:
      the new instance.
      Since:
      2.3.0
    • expandFeatureIdWildcard

      public static Stream<org.eclipse.ditto.json.JsonPointer> expandFeatureIdWildcard(Collection<org.eclipse.ditto.json.JsonKey> featureIds, org.eclipse.ditto.json.JsonPointer jsonPointer)
      Returns a stream of JsonPointer with expanded feature id wildcard.
      Returns:
      a stream of JsonPointer.
      Since:
      2.3.0