Class ObjectIdGenerators.UUIDGenerator

  • All Implemented Interfaces:
    Enclosing class:

    public static final class ObjectIdGenerators.UUIDGenerator
    extends ObjectIdGenerator<T>
    Implementation that just uses UUIDs as reliably unique identifiers: downside is that resulting String is 36 characters long.

    One difference to other generators is that scope is always set as Object.class (regardless of arguments): this because UUIDs are globally unique, and scope has no meaning.

    See Also:
    Serialized Form
    • Constructor Detail

      • UUIDGenerator

        public UUIDGenerator()
    • Method Detail

      • forScope

        public ObjectIdGenerator<java.util.UUID> forScope​(java.lang.Class<?> scope)
        Can just return base instance since this is essentially scopeless
        Specified by:
        forScope in class ObjectIdGenerator<java.util.UUID>
      • newForSerialization

        public ObjectIdGenerator<java.util.UUID> newForSerialization​(java.lang.Object context)
        Can just return base instance since this is essentially scopeless
        Specified by:
        newForSerialization in class ObjectIdGenerator<java.util.UUID>
        context - Serialization context object used (of type com.fasterxml.jackson.databind.SerializerProvider; may be needed by more complex generators to access contextual information such as configuration.
      • generateId

        public java.util.UUID generateId​(java.lang.Object forPojo)
        Description copied from class: ObjectIdGenerator
        Method used for generating a new Object Identifier to serialize for given POJO.
        forPojo - POJO for which identifier is needed
        Object Identifier to use.
      • canUseFor

        public boolean canUseFor​(ObjectIdGenerator<?> gen)
        Since UUIDs are always unique, let's fully ignore scope definition
        True if this instance can be used as-is; false if not