com.fasterxml.jackson.annotation
Class SimpleObjectIdResolver

java.lang.Object
  extended by com.fasterxml.jackson.annotation.SimpleObjectIdResolver
All Implemented Interfaces:
ObjectIdResolver

public class SimpleObjectIdResolver
extends Object
implements ObjectIdResolver

Simple implementation of ObjectIdResolver

Author:
Pascal Gélinas

Field Summary
protected  Map<ObjectIdGenerator.IdKey,Object> _items
           
 
Constructor Summary
SimpleObjectIdResolver()
           
 
Method Summary
 void bindItem(ObjectIdGenerator.IdKey id, Object ob)
          Method called when a POJO is deserialized and has an Object Identifier.
 boolean canUseFor(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 (using ObjectIdResolver.newForDeserialization(java.lang.Object)).
 ObjectIdResolver 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).
 Object resolveId(ObjectIdGenerator.IdKey id)
          Method called when deserialization encounters the given Object Identifier and requires the POJO associated with it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_items

protected Map<ObjectIdGenerator.IdKey,Object> _items
Constructor Detail

SimpleObjectIdResolver

public SimpleObjectIdResolver()
Method Detail

bindItem

public void bindItem(ObjectIdGenerator.IdKey id,
                     Object ob)
Description copied from interface: ObjectIdResolver
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.

Specified by:
bindItem in interface ObjectIdResolver
Parameters:
id - The Object Identifer
ob - The POJO associated to that Identifier

resolveId

public Object resolveId(ObjectIdGenerator.IdKey id)
Description copied from interface: ObjectIdResolver
Method called when deserialization encounters the given Object Identifier and requires the POJO associated with it.

Specified by:
resolveId in interface ObjectIdResolver
Parameters:
id - The Object Identifier
Returns:
The POJO, or null if unable to resolve.

canUseFor

public boolean canUseFor(ObjectIdResolver resolverType)
Description copied from interface: ObjectIdResolver
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 (using ObjectIdResolver.newForDeserialization(java.lang.Object)).

Specified by:
canUseFor in interface ObjectIdResolver
Returns:
True if this instance can be used as-is; false if not

newForDeserialization

public ObjectIdResolver newForDeserialization(Object context)
Description copied from interface: ObjectIdResolver
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 com.fasterxml.jackson.databind.DeserializationContext, but can not be declared here as type itself (as well as call to this object) comes from databind package.

Specified by:
newForDeserialization in interface ObjectIdResolver
Parameters:
context - Deserialization context object used (of type com.fasterxml.jackson.databind.DeserializationContext ; may be needed by more complex resolvers to access contextual information such as configuration.


Copyright © 2008–2016 FasterXML. All rights reserved.