Class ObjectIdGenerator<T>

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  ObjectIdGenerator.IdKey
      Simple key class that can be used as a key for ObjectId-to-POJO mappings, when multiple ObjectId types and scopes are used.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      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)).
      abstract ObjectIdGenerator<T> forScope​(java.lang.Class<?> scope)
      Factory method to create a blueprint instance for specified scope.
      abstract T generateId​(java.lang.Object forPojo)
      Method used for generating a new Object Identifier to serialize for given POJO.
      abstract java.lang.Class<?> getScope()  
      boolean isValidReferencePropertyName​(java.lang.String name, java.lang.Object parser)
      Accessor that may be called (after verifying (via maySerializeAsObject()) whether given name
      abstract ObjectIdGenerator.IdKey key​(java.lang.Object key)
      Method for constructing key to use for ObjectId-to-POJO maps.
      boolean maySerializeAsObject()
      Accessor that needs to be overridden to return true if the Object Id may be serialized as JSON Object; used by, for example, JSOG handling.
      abstract ObjectIdGenerator<T> newForSerialization​(java.lang.Object context)
      Factory method called to create a new instance to use for serialization: needed since generators may have state (next id to produce).
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ObjectIdGenerator

        public ObjectIdGenerator()
    • Method Detail

      • getScope

        public abstract java.lang.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
      • maySerializeAsObject

        public boolean maySerializeAsObject()
        Accessor that needs to be overridden to return true if the Object Id may be serialized as JSON Object; used by, for example, JSOG handling. The reason accessor is needed is because handling such Object Ids is more complex and may incur additional buffering or performance overhead, avoiding of which makes sense for common case of scalar object ids (or native object ids some formats support).

        Default implementation returns false, so needs to be overridden by Object-producing generators.

        Since:
        2.5
      • isValidReferencePropertyName

        public boolean isValidReferencePropertyName​(java.lang.String name,
                                                    java.lang.Object parser)
        Accessor that may be called (after verifying (via maySerializeAsObject()) whether given name
        Parameters:
        name - Name of property to check
        parser - Parser that points to property name, in case generator needs further verification (note: untyped, because JsonParser is defined in `jackson-core`, and this package does not depend on it).
        Since:
        2.5
      • forScope

        public abstract ObjectIdGenerator<T> forScope​(java.lang.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​(java.lang.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.
      • key

        public abstract ObjectIdGenerator.IdKey key​(java.lang.Object key)
        Method for constructing key to use for ObjectId-to-POJO maps.
      • generateId

        public abstract T generateId​(java.lang.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.