Class ThingId

java.lang.Object
org.eclipse.ditto.base.model.entity.id.AbstractEntityId
org.eclipse.ditto.base.model.entity.id.AbstractNamespacedEntityId
org.eclipse.ditto.things.model.ThingId
All Implemented Interfaces:
CharSequence, Comparable<org.eclipse.ditto.base.model.entity.id.EntityId>, org.eclipse.ditto.base.model.entity.id.EntityId, org.eclipse.ditto.base.model.entity.id.NamespacedEntityId

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

    Modifier and Type
    Method
    Description
    static ThingId
    Generates a new thing ID with the default namespace placeholder and a unique name.
    static ThingId
    Generates a new thing ID with the specified namespace placeholder or a default namespace if null is passed along with a unique name
    static ThingId
    Returns an instance of this class with default namespace placeholder.
    static ThingId
    Generates a thing ID with a random unique name inside the given namespace.
    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.base.model.entity.id.AbstractNamespacedEntityId

    getName, getNamespace

    Methods inherited from class org.eclipse.ditto.base.model.entity.id.AbstractEntityId

    equals, getEntityType, hashCode, toString

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface java.lang.CharSequence

    chars, codePoints, isEmpty, toString

    Methods inherited from interface org.eclipse.ditto.base.model.entity.id.EntityId

    charAt, compareTo, getEntityType, length, subSequence
  • Method Details

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

      public static ThingId inNamespaceWithRandomName(String namespace)
      Generates a thing ID with a random unique name inside the given namespace.
      Parameters:
      namespace - the namespace of the thing.
      Returns:
      The generated unique thing ID.
      Throws:
      ThingIdInvalidException - if for the given namespace a ThingId cannot be derived.
      Since:
      3.0.0
    • 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.
    • generateRandom

      public static ThingId generateRandom(@Nullable String namespace)
      Generates a new thing ID with the specified namespace placeholder or a default namespace if null is passed along with a unique name
      Parameters:
      namespace - the specified namespace
      Returns:
      the generated thing ID