Package com.fasterxml.jackson.annotation
Class ObjectIdGenerators.UUIDGenerator
java.lang.Object
com.fasterxml.jackson.annotation.ObjectIdGenerator<UUID>
com.fasterxml.jackson.annotation.ObjectIdGenerators.UUIDGenerator
- All Implemented Interfaces:
Serializable
- Enclosing class:
ObjectIdGenerators
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:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.fasterxml.jackson.annotation.ObjectIdGenerator
ObjectIdGenerator.IdKey -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancanUseFor(ObjectIdGenerator<?> gen) Since UUIDs are always unique, let's fully ignore scope definitionCan just return base instance since this is essentially scopelessgenerateId(Object forPojo) Method used for generating a new Object Identifier to serialize for given POJO.final Class<?> getScope()Method for constructing key to use for ObjectId-to-POJO maps.newForSerialization(Object context) Can just return base instance since this is essentially scopelessMethods inherited from class com.fasterxml.jackson.annotation.ObjectIdGenerator
isValidReferencePropertyName, maySerializeAsObject
-
Constructor Details
-
UUIDGenerator
public UUIDGenerator()
-
-
Method Details
-
forScope
Can just return base instance since this is essentially scopeless- Specified by:
forScopein classObjectIdGenerator<UUID>
-
newForSerialization
Can just return base instance since this is essentially scopeless- Specified by:
newForSerializationin classObjectIdGenerator<UUID>- Parameters:
context- Serialization context object used (of typecom.fasterxml.jackson.databind.SerializerProvider); may be needed by more complex generators to access contextual information such as configuration.
-
generateId
Description copied from class:ObjectIdGeneratorMethod used for generating a new Object Identifier to serialize for given POJO.- Parameters:
forPojo- POJO for which identifier is needed- Returns:
- Object Identifier to use.
-
key
Description copied from class:ObjectIdGeneratorMethod for constructing key to use for ObjectId-to-POJO maps.- Specified by:
keyin classObjectIdGenerator<UUID>
-
canUseFor
Since UUIDs are always unique, let's fully ignore scope definition- Returns:
- True if this instance can be used as-is; false if not
-
getScope
- Specified by:
getScopein classObjectIdGenerator<T>
-