Package com.fasterxml.jackson.annotation
Class SimpleObjectIdResolver
- java.lang.Object
-
- com.fasterxml.jackson.annotation.SimpleObjectIdResolver
-
- All Implemented Interfaces:
ObjectIdResolver
public class SimpleObjectIdResolver extends java.lang.Object implements ObjectIdResolver
Simple implementation ofObjectIdResolver- Author:
- Pascal Gélinas
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Map<ObjectIdGenerator.IdKey,java.lang.Object>_items
-
Constructor Summary
Constructors Constructor Description SimpleObjectIdResolver()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbindItem(ObjectIdGenerator.IdKey id, java.lang.Object ob)Method called when a POJO is deserialized and has an Object Identifier.booleancanUseFor(ObjectIdResolver resolverType)Method called to check whether this resolver instance can be used for Object Ids of specific resolver type; determination is based by passing a configured "blueprint" (prototype) instance; from which the actual instances are created (usingObjectIdResolver.newForDeserialization(java.lang.Object)).ObjectIdResolvernewForDeserialization(java.lang.Object context)Factory method called to create a new instance to use for deserialization: needed since resolvers may have state (a pool of objects).java.lang.ObjectresolveId(ObjectIdGenerator.IdKey id)Method called when deserialization encounters the given Object Identifier and requires the POJO associated with it.
-
-
-
Field Detail
-
_items
protected java.util.Map<ObjectIdGenerator.IdKey,java.lang.Object> _items
-
-
Method Detail
-
bindItem
public void bindItem(ObjectIdGenerator.IdKey id, java.lang.Object ob)
Description copied from interface:ObjectIdResolverMethod called when a POJO is deserialized and has an Object Identifier. Method exists so that implementation can keep track of existing object in JSON stream that could be useful for further resolution.- Specified by:
bindItemin interfaceObjectIdResolver- Parameters:
id- The Object Identifierob- The POJO associated to that Identifier
-
resolveId
public java.lang.Object resolveId(ObjectIdGenerator.IdKey id)
Description copied from interface:ObjectIdResolverMethod called when deserialization encounters the given Object Identifier and requires the POJO associated with it.- Specified by:
resolveIdin interfaceObjectIdResolver- Parameters:
id- The Object Identifier- Returns:
- The POJO, or null if unable to resolve.
-
canUseFor
public boolean canUseFor(ObjectIdResolver resolverType)
Description copied from interface:ObjectIdResolverMethod called to check whether this resolver instance can be used for Object Ids of specific resolver type; determination is based by passing a configured "blueprint" (prototype) instance; from which the actual instances are created (usingObjectIdResolver.newForDeserialization(java.lang.Object)).- Specified by:
canUseForin interfaceObjectIdResolver- Returns:
- True if this instance can be used as-is; false if not
-
newForDeserialization
public ObjectIdResolver newForDeserialization(java.lang.Object context)
Description copied from interface:ObjectIdResolverFactory method called to create a new instance to use for deserialization: needed since resolvers may have state (a pool of objects).Note that actual type of 'context' is
DeserializationContext, but can not be declared here as type itself (as well as call to this object) comes from databind package.- Specified by:
newForDeserializationin interfaceObjectIdResolver- Parameters:
context- Deserialization context object used (of typeDeserializationContext) ; may be needed by more complex resolvers to access contextual information such as configuration.
-
-