Class ThingId

  • All Implemented Interfaces:
    CharSequence, Comparable<org.eclipse.ditto.model.base.entity.id.EntityId>, org.eclipse.ditto.model.base.entity.id.EntityId, org.eclipse.ditto.model.base.entity.id.NamespacedEntityId, org.eclipse.ditto.model.base.entity.type.WithEntityType

    @Immutable
    public final class ThingId
    extends org.eclipse.ditto.model.base.entity.id.NamespacedEntityIdWithType
    Java representation of a validated Thing ID.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static ThingId dummy()
      Returns a dummy ThingId.
      static ThingId generateRandom()
      Generates a new thing ID with the default namespace placeholder and a unique name.
      org.eclipse.ditto.model.base.entity.type.EntityType getEntityType()
      Returns the entity type of a Thing.
      static ThingId inDefaultNamespace​(String name)
      Returns an instance of this class with default namespace placeholder.
      static ThingId of​(CharSequence thingId)
      Returns an instance of this class based on the given CharSequence.
      static ThingId of​(String namespace, String name)
      Returns an instance of this class with the given namespace and name.
      • Methods inherited from class org.eclipse.ditto.model.base.entity.id.NamespacedEntityIdWithType

        equals, getName, getNamespace, hashCode, isCompatibleOrThrow
      • Methods inherited from class org.eclipse.ditto.model.base.entity.id.EntityIdWithType

        createEqualityValidator, getIllegalArgumentExceptionForDifferentEntityIds, isDummy, toString
      • Methods inherited from interface org.eclipse.ditto.model.base.entity.id.EntityId

        charAt, compareTo, isDummy, length, subSequence
    • Method Detail

      • of

        public static ThingId of​(CharSequence thingId)
        Returns an instance of this class based on the given CharSequence. May return the same instance as the parameter if the given parameter is already a ThingId. Skips validation if the given thingId is an instance of NamespacedEntityId.
        Parameters:
        thingId - the thing ID.
        Returns:
        the ID.
        Throws:
        ThingIdInvalidException - if the given thingId is invalid.
      • of

        public static ThingId of​(String namespace,
                                 String name)
        Returns an instance of this class with the given namespace and name.
        Parameters:
        namespace - the namespace of the thing.
        name - the name of the thing.
        Returns:
        the created ID.
      • inDefaultNamespace

        public static ThingId inDefaultNamespace​(String name)
        Returns an instance of this class with default namespace placeholder.
        Parameters:
        name - the name of the thing.
        Returns:
        the created ID.
        Throws:
        ThingIdInvalidException - if for the given name a ThingId cannot be derived.
      • generateRandom

        public static ThingId generateRandom()
        Generates a new thing ID with the default namespace placeholder and a unique name.
        Returns:
        the generated thing ID.
      • dummy

        public static ThingId dummy()
        Returns a dummy ThingId. This ID should not be used for entities. It can be identified by checking EntityIdWithType.isDummy().
        Returns:
        the dummy ID.
      • getEntityType

        public org.eclipse.ditto.model.base.entity.type.EntityType getEntityType()
        Returns the entity type of a Thing.
        Returns:
        always ThingConstants.ENTITY_TYPE.
        Since:
        1.1.0