com.fasterxml.jackson.annotation

Class ObjectIdGenerator<T>

    • Constructor Detail

      • ObjectIdGenerator

        public ObjectIdGenerator()
    • Method Detail

      • getScope

        public abstract Class<?> getScope()
      • canUseFor

        public abstract boolean canUseFor(ObjectIdGenerator<?> gen)
        Method called to check whether this generator instance can be used for Object Ids of specific generator type and scope; determination is based by passing a configured "blueprint" (prototype) instance; from which the actual instances are created (using newForSerialization(java.lang.Object)).
        Returns:
        True if this instance can be used as-is; false if not
      • forScope

        public abstract ObjectIdGenerator<T> forScope(Class<?> scope)
        Factory method to create a blueprint instance for specified scope. Generators that do not use scope may return 'this'.
      • newForSerialization

        public abstract ObjectIdGenerator<T> newForSerialization(Object context)
        Factory method called to create a new instance to use for serialization: needed since generators may have state (next id to produce).

        Note that actual type of 'context' is com.fasterxml.jackson.databind.SerializerProvider, but can not be declared here as type itself (as well as call to this object) comes from databind package.

        Parameters:
        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 abstract T generateId(Object forPojo)
        Method 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.

Copyright © 2012-2014 FasterXML. All Rights Reserved.