com.fasterxml.jackson.databind.module
Class SimpleDeserializers

java.lang.Object
  extended by com.fasterxml.jackson.databind.module.SimpleDeserializers
All Implemented Interfaces:
Deserializers

public class SimpleDeserializers
extends Object
implements Deserializers

Simple implementation Deserializers which allows registration of deserializers based on raw (type erased class). It can work well for basic bean and scalar type deserializers, but is not a good fit for handling generic types (like Maps and Collections or array types).

Unlike SimpleSerializers, this class does not currently support generic mappings; all mappings must be to exact declared deserialization type.


Nested Class Summary
 
Nested classes/interfaces inherited from interface com.fasterxml.jackson.databind.deser.Deserializers
Deserializers.Base
 
Field Summary
protected  HashMap<ClassKey,JsonDeserializer<?>> _classMappings
           
 
Constructor Summary
SimpleDeserializers()
           
 
Method Summary
<T> void
addDeserializer(Class<T> forClass, JsonDeserializer<? extends T> deser)
           
 JsonDeserializer<?> findArrayDeserializer(ArrayType type, DeserializationConfig config, BeanDescription beanDesc, TypeDeserializer elementTypeDeserializer, JsonDeserializer<?> elementDeserializer)
          Method called to locate serializer for specified array type.
 JsonDeserializer<?> findBeanDeserializer(JavaType type, DeserializationConfig config, BeanDescription beanDesc)
          Method called to locate deserializer for specified value type which does not belong to any other category (not an Enum, Collection, Map, Array or tree node)
 JsonDeserializer<?> findCollectionDeserializer(CollectionType type, DeserializationConfig config, BeanDescription beanDesc, TypeDeserializer elementTypeDeserializer, JsonDeserializer<?> elementDeserializer)
          Method called to locate serializer for specified Collection (List, Set etc) type.
 JsonDeserializer<?> findCollectionLikeDeserializer(CollectionLikeType type, DeserializationConfig config, BeanDescription beanDesc, TypeDeserializer elementTypeDeserializer, JsonDeserializer<?> elementDeserializer)
          Method called to locate serializer for specified "Collection-like" type (one that acts like Collection but does not implement it).
 JsonDeserializer<?> findEnumDeserializer(Class<?> type, DeserializationConfig config, BeanDescription beanDesc)
          Method called to locate deserializer for specified Enum type.
 JsonDeserializer<?> findMapDeserializer(MapType type, DeserializationConfig config, BeanDescription beanDesc, KeyDeserializer keyDeserializer, TypeDeserializer elementTypeDeserializer, JsonDeserializer<?> elementDeserializer)
          Method called to locate deserializer for specified Map type.
 JsonDeserializer<?> findMapLikeDeserializer(MapLikeType type, DeserializationConfig config, BeanDescription beanDesc, KeyDeserializer keyDeserializer, TypeDeserializer elementTypeDeserializer, JsonDeserializer<?> elementDeserializer)
          Method called to locate serializer for specified "Map-like" type (one that acts like Map but does not implement it).
 JsonDeserializer<?> findTreeNodeDeserializer(Class<? extends JsonNode> nodeType, DeserializationConfig config, BeanDescription beanDesc)
          Method called to locate deserializer for specified JSON tree node type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_classMappings

protected HashMap<ClassKey,JsonDeserializer<?>> _classMappings
Constructor Detail

SimpleDeserializers

public SimpleDeserializers()
Method Detail

addDeserializer

public <T> void addDeserializer(Class<T> forClass,
                                JsonDeserializer<? extends T> deser)

findArrayDeserializer

public JsonDeserializer<?> findArrayDeserializer(ArrayType type,
                                                 DeserializationConfig config,
                                                 BeanDescription beanDesc,
                                                 TypeDeserializer elementTypeDeserializer,
                                                 JsonDeserializer<?> elementDeserializer)
                                          throws JsonMappingException
Description copied from interface: Deserializers
Method called to locate serializer for specified array type.

Deserializer for element type may be passed, if configured explicitly at higher level (by annotations, typically), but usually are not. Type deserializer for element is passed if one is needed based on contextual information (annotations on declared element class; or on field or method type is associated with).

Specified by:
findArrayDeserializer in interface Deserializers
Parameters:
type - Type of array instances to deserialize
config - Configuration in effect
beanDesc - Definition of the enumeration type that contains class annotations and other information typically needed for building deserializers
elementTypeDeserializer - If element type needs polymorphic type handling, this is the type information deserializer to use; should usually be used as is when constructing array deserializer.
elementDeserializer - Deserializer to use for elements, if explicitly defined (by using annotations, for exmple). May be null, in which case it should be resolved here (or using ResolvableDeserializer callback)
Returns:
Deserializer to use for the type; or null if this provider does not know how to construct it
Throws:
JsonMappingException

findBeanDeserializer

public JsonDeserializer<?> findBeanDeserializer(JavaType type,
                                                DeserializationConfig config,
                                                BeanDescription beanDesc)
                                         throws JsonMappingException
Description copied from interface: Deserializers
Method called to locate deserializer for specified value type which does not belong to any other category (not an Enum, Collection, Map, Array or tree node)

Specified by:
findBeanDeserializer in interface Deserializers
Parameters:
type - Bean type to deserialize
config - Configuration in effect
beanDesc - Definition of the enumeration type that contains class annotations and other information typically needed for building deserializers
Returns:
Deserializer to use for the type; or null if this provider does not know how to construct it
Throws:
JsonMappingException

findCollectionDeserializer

public JsonDeserializer<?> findCollectionDeserializer(CollectionType type,
                                                      DeserializationConfig config,
                                                      BeanDescription beanDesc,
                                                      TypeDeserializer elementTypeDeserializer,
                                                      JsonDeserializer<?> elementDeserializer)
                                               throws JsonMappingException
Description copied from interface: Deserializers
Method called to locate serializer for specified Collection (List, Set etc) type.

Deserializer for element type may be passed, if configured explicitly at higher level (by annotations, typically), but usually are not. Type deserializer for element is passed if one is needed based on contextual information (annotations on declared element class; or on field or method type is associated with).

Specified by:
findCollectionDeserializer in interface Deserializers
Parameters:
type - Type of collection instances to deserialize
config - Configuration in effect
beanDesc - Definition of the enumeration type that contains class annotations and other information typically needed for building deserializers
elementTypeDeserializer - If element type needs polymorphic type handling, this is the type information deserializer to use; should usually be used as is when constructing array deserializer.
elementDeserializer - Deserializer to use for elements, if explicitly defined (by using annotations, for exmple). May be null, in which case it should be resolved here (or using ResolvableDeserializer callback)
Returns:
Deserializer to use for the type; or null if this provider does not know how to construct it
Throws:
JsonMappingException

findCollectionLikeDeserializer

public JsonDeserializer<?> findCollectionLikeDeserializer(CollectionLikeType type,
                                                          DeserializationConfig config,
                                                          BeanDescription beanDesc,
                                                          TypeDeserializer elementTypeDeserializer,
                                                          JsonDeserializer<?> elementDeserializer)
                                                   throws JsonMappingException
Description copied from interface: Deserializers
Method called to locate serializer for specified "Collection-like" type (one that acts like Collection but does not implement it).

Deserializer for element type may be passed, if configured explicitly at higher level (by annotations, typically), but usually are not. Type deserializer for element is passed if one is needed based on contextual information (annotations on declared element class; or on field or method type is associated with).

Specified by:
findCollectionLikeDeserializer in interface Deserializers
Parameters:
type - Type of instances to deserialize
config - Configuration in effect
beanDesc - Definition of the enumeration type that contains class annotations and other information typically needed for building deserializers
elementTypeDeserializer - If element type needs polymorphic type handling, this is the type information deserializer to use; should usually be used as is when constructing array deserializer.
elementDeserializer - Deserializer to use for elements, if explicitly defined (by using annotations, for exmple). May be null, in which case it should be resolved here (or using ResolvableDeserializer callback)
Returns:
Deserializer to use for the type; or null if this provider does not know how to construct it
Throws:
JsonMappingException

findEnumDeserializer

public JsonDeserializer<?> findEnumDeserializer(Class<?> type,
                                                DeserializationConfig config,
                                                BeanDescription beanDesc)
                                         throws JsonMappingException
Description copied from interface: Deserializers
Method called to locate deserializer for specified Enum type.

Specified by:
findEnumDeserializer in interface Deserializers
Parameters:
type - Type of Enum instances to deserialize
config - Configuration in effect
beanDesc - Definition of the enumeration type that contains class annotations and other information typically needed for building deserializers
Returns:
Deserializer to use for the type; or null if this provider does not know how to construct it
Throws:
JsonMappingException

findMapDeserializer

public JsonDeserializer<?> findMapDeserializer(MapType type,
                                               DeserializationConfig config,
                                               BeanDescription beanDesc,
                                               KeyDeserializer keyDeserializer,
                                               TypeDeserializer elementTypeDeserializer,
                                               JsonDeserializer<?> elementDeserializer)
                                        throws JsonMappingException
Description copied from interface: Deserializers
Method called to locate deserializer for specified Map type.

Deserializer for element type may be passed, if configured explicitly at higher level (by annotations, typically), but usually are not. Type deserializer for element is passed if one is needed based on contextual information (annotations on declared element class; or on field or method type is associated with).

Similarly, a KeyDeserializer may be passed, but this is only done if there is a specific configuration override (annotations) to indicate instance to use. Otherwise null is passed, and key deserializer needs to be obtained later during resolution (using ResolvableDeserializer.resolve(com.fasterxml.jackson.databind.DeserializationContext)).

Specified by:
findMapDeserializer in interface Deserializers
Parameters:
type - Type of Map instances to deserialize
config - Configuration in effect
beanDesc - Definition of the enumeration type that contains class annotations and other information typically needed for building deserializers
keyDeserializer - Key deserializer use, if it is defined via annotations or other configuration; null if default key deserializer for key type can be used.
elementTypeDeserializer - If element type needs polymorphic type handling, this is the type information deserializer to use; should usually be used as is when constructing array deserializer.
elementDeserializer - Deserializer to use for elements, if explicitly defined (by using annotations, for exmple). May be null, in which case it should be resolved here (or using ResolvableDeserializer callback)
Returns:
Deserializer to use for the type; or null if this provider does not know how to construct it
Throws:
JsonMappingException

findMapLikeDeserializer

public JsonDeserializer<?> findMapLikeDeserializer(MapLikeType type,
                                                   DeserializationConfig config,
                                                   BeanDescription beanDesc,
                                                   KeyDeserializer keyDeserializer,
                                                   TypeDeserializer elementTypeDeserializer,
                                                   JsonDeserializer<?> elementDeserializer)
                                            throws JsonMappingException
Description copied from interface: Deserializers
Method called to locate serializer for specified "Map-like" type (one that acts like Map but does not implement it).

Deserializer for element type may be passed, if configured explicitly at higher level (by annotations, typically), but usually are not. Type deserializer for element is passed if one is needed based on contextual information (annotations on declared element class; or on field or method type is associated with).

Similarly, a KeyDeserializer may be passed, but this is only done if there is a specific configuration override (annotations) to indicate instance to use. Otherwise null is passed, and key deserializer needs to be obtained later during resolution (using ResolvableDeserializer.resolve(com.fasterxml.jackson.databind.DeserializationContext)).

Specified by:
findMapLikeDeserializer in interface Deserializers
Parameters:
type - Type of Map instances to deserialize
config - Configuration in effect
beanDesc - Definition of the enumeration type that contains class annotations and other information typically needed for building deserializers
keyDeserializer - Key deserializer use, if it is defined via annotations or other configuration; null if default key deserializer for key type can be used.
elementTypeDeserializer - If element type needs polymorphic type handling, this is the type information deserializer to use; should usually be used as is when constructing array deserializer.
elementDeserializer - Deserializer to use for elements, if explicitly defined (by using annotations, for exmple). May be null, in which case it should be resolved here (or using ResolvableDeserializer callback)
Returns:
Deserializer to use for the type; or null if this provider does not know how to construct it
Throws:
JsonMappingException

findTreeNodeDeserializer

public JsonDeserializer<?> findTreeNodeDeserializer(Class<? extends JsonNode> nodeType,
                                                    DeserializationConfig config,
                                                    BeanDescription beanDesc)
                                             throws JsonMappingException
Description copied from interface: Deserializers
Method called to locate deserializer for specified JSON tree node type.

Specified by:
findTreeNodeDeserializer in interface Deserializers
Parameters:
nodeType - Specific type of JSON tree nodes to deserialize (subtype of JsonNode)
config - Configuration in effect
Returns:
Deserializer to use for the type; or null if this provider does not know how to construct it
Throws:
JsonMappingException


Copyright © 2012 fasterxml.com. All Rights Reserved.