Package com.fasterxml.jackson.annotation
Interface ObjectIdResolver
- All Known Implementing Classes:
SimpleObjectIdResolver
public interface ObjectIdResolver
Definition of API used for resolving actual Java object from
Object Identifiers (as annotated using
JsonIdentityInfo).- Since:
- 2.4
-
Method Summary
Modifier and TypeMethodDescriptionvoidbindItem(ObjectIdGenerator.IdKey id, Object pojo) 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 (usingnewForDeserialization(java.lang.Object)).newForDeserialization(Object context) Factory method called to create a new instance to use for deserialization: needed since resolvers may have state (a pool of objects).Method called when deserialization encounters the given Object Identifier and requires the POJO associated with it.
-
Method Details
-
bindItem
Method 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.- Parameters:
id- The Object Identifierpojo- The POJO associated to that Identifier
-
resolveId
Method called when deserialization encounters the given Object Identifier and requires the POJO associated with it.- Parameters:
id- The Object Identifier- Returns:
- The POJO, or null if unable to resolve.
-
newForDeserialization
Factory 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.- Parameters:
context- Deserialization context object used (of typeDeserializationContext) ; may be needed by more complex resolvers to access contextual information such as configuration.
-
canUseFor
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 (usingnewForDeserialization(java.lang.Object)).- Returns:
- True if this instance can be used as-is; false if not
-