Class SimpleDeserializers
- java.lang.Object
-
- com.fasterxml.jackson.databind.deser.Deserializers.Base
-
- com.fasterxml.jackson.databind.module.SimpleDeserializers
-
- All Implemented Interfaces:
Deserializers,java.io.Serializable
public class SimpleDeserializers extends Deserializers.Base implements java.io.Serializable
Simple implementationDeserializerswhich 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 (likeMaps andCollections or array types).Unlike
SimpleSerializers, this class does not currently support generic mappings; all mappings must be to exact declared deserialization type.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.fasterxml.jackson.databind.deser.Deserializers
Deserializers.Base
-
-
Constructor Summary
Constructors Constructor Description SimpleDeserializers()SimpleDeserializers(java.util.Map<java.lang.Class<?>,JsonDeserializer<?>> desers)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> voidaddDeserializer(java.lang.Class<T> forClass, JsonDeserializer<? extends T> deser)voidaddDeserializers(java.util.Map<java.lang.Class<?>,JsonDeserializer<?>> desers)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, reference value or tree node)JsonDeserializer<?>findCollectionDeserializer(CollectionType type, DeserializationConfig config, BeanDescription beanDesc, TypeDeserializer elementTypeDeserializer, JsonDeserializer<?> elementDeserializer)Method called to locate serializer for specifiedCollection(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 likeCollectionbut does not implement it).JsonDeserializer<?>findEnumDeserializer(java.lang.Class<?> type, DeserializationConfig config, BeanDescription beanDesc)Method called to locate deserializer for specifiedEnumtype.JsonDeserializer<?>findMapDeserializer(MapType type, DeserializationConfig config, BeanDescription beanDesc, KeyDeserializer keyDeserializer, TypeDeserializer elementTypeDeserializer, JsonDeserializer<?> elementDeserializer)Method called to locate deserializer for specifiedMaptype.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 likeMapbut does not implement it).JsonDeserializer<?>findReferenceDeserializer(ReferenceType refType, DeserializationConfig config, BeanDescription beanDesc, TypeDeserializer contentTypeDeserializer, JsonDeserializer<?> contentDeserializer)Method called to locate deserializer for value that is of referential type,JsonDeserializer<?>findTreeNodeDeserializer(java.lang.Class<? extends JsonNode> nodeType, DeserializationConfig config, BeanDescription beanDesc)Method called to locate deserializer for specified JSON tree node type.booleanhasDeserializerFor(DeserializationConfig config, java.lang.Class<?> valueType)Method that may be called to check whether this deserializer provider would provide deserializer for values of given type, without attempting to construct (and possibly fail in some cases) actual deserializer.
-
-
-
Constructor Detail
-
SimpleDeserializers
public SimpleDeserializers()
-
SimpleDeserializers
public SimpleDeserializers(java.util.Map<java.lang.Class<?>,JsonDeserializer<?>> desers)
- Since:
- 2.1
-
-
Method Detail
-
addDeserializer
public <T> void addDeserializer(java.lang.Class<T> forClass, JsonDeserializer<? extends T> deser)
-
addDeserializers
public void addDeserializers(java.util.Map<java.lang.Class<?>,JsonDeserializer<?>> desers)
- Since:
- 2.1
-
findArrayDeserializer
public JsonDeserializer<?> findArrayDeserializer(ArrayType type, DeserializationConfig config, BeanDescription beanDesc, TypeDeserializer elementTypeDeserializer, JsonDeserializer<?> elementDeserializer) throws JsonMappingException
Description copied from interface:DeserializersMethod 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:
findArrayDeserializerin interfaceDeserializers- Overrides:
findArrayDeserializerin classDeserializers.Base- Parameters:
type- Type of array instances to deserializeconfig- Configuration in effectbeanDesc- Definition of the enumeration type that contains class annotations and other information typically needed for building deserializerselementTypeDeserializer- 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 usingResolvableDeserializercallback)- 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:DeserializersMethod called to locate deserializer for specified value type which does not belong to any other category (not an Enum, Collection, Map, Array, reference value or tree node)- Specified by:
findBeanDeserializerin interfaceDeserializers- Overrides:
findBeanDeserializerin classDeserializers.Base- Parameters:
type- Bean type to deserializeconfig- Configuration in effectbeanDesc- 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:DeserializersMethod called to locate serializer for specifiedCollection(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:
findCollectionDeserializerin interfaceDeserializers- Overrides:
findCollectionDeserializerin classDeserializers.Base- Parameters:
type- Type of collection instances to deserializeconfig- Configuration in effectbeanDesc- Definition of the enumeration type that contains class annotations and other information typically needed for building deserializerselementTypeDeserializer- 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 usingResolvableDeserializercallback)- 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:DeserializersMethod called to locate serializer for specified "Collection-like" type (one that acts likeCollectionbut 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:
findCollectionLikeDeserializerin interfaceDeserializers- Overrides:
findCollectionLikeDeserializerin classDeserializers.Base- Parameters:
type- Type of instances to deserializeconfig- Configuration in effectbeanDesc- Definition of the enumeration type that contains class annotations and other information typically needed for building deserializerselementTypeDeserializer- 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 usingResolvableDeserializercallback)- 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(java.lang.Class<?> type, DeserializationConfig config, BeanDescription beanDesc) throws JsonMappingException
Description copied from interface:DeserializersMethod called to locate deserializer for specifiedEnumtype.- Specified by:
findEnumDeserializerin interfaceDeserializers- Overrides:
findEnumDeserializerin classDeserializers.Base- Parameters:
type- Type ofEnuminstances to deserializeconfig- Configuration in effectbeanDesc- 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
-
findTreeNodeDeserializer
public JsonDeserializer<?> findTreeNodeDeserializer(java.lang.Class<? extends JsonNode> nodeType, DeserializationConfig config, BeanDescription beanDesc) throws JsonMappingException
Description copied from interface:DeserializersMethod called to locate deserializer for specified JSON tree node type.- Specified by:
findTreeNodeDeserializerin interfaceDeserializers- Overrides:
findTreeNodeDeserializerin classDeserializers.Base- Parameters:
nodeType- Specific type of JSON tree nodes to deserialize (subtype ofJsonNode)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
-
findReferenceDeserializer
public JsonDeserializer<?> findReferenceDeserializer(ReferenceType refType, DeserializationConfig config, BeanDescription beanDesc, TypeDeserializer contentTypeDeserializer, JsonDeserializer<?> contentDeserializer) throws JsonMappingException
Description copied from interface:DeserializersMethod called to locate deserializer for value that is of referential type,- Specified by:
findReferenceDeserializerin interfaceDeserializers- Overrides:
findReferenceDeserializerin classDeserializers.Base- Parameters:
refType- Specific referential type to deserializeconfig- Configuration in effectbeanDesc- Definition of the reference type that contains class annotations and other information typically needed for building deserializerscontentTypeDeserializer- Possible type deserializer for referenced valuecontentDeserializer- Value deserializer to use for referenced value, if indicated by property annotation- 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:DeserializersMethod called to locate deserializer for specifiedMaptype.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
KeyDeserializermay 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 (usingResolvableDeserializer.resolve(com.fasterxml.jackson.databind.DeserializationContext)).- Specified by:
findMapDeserializerin interfaceDeserializers- Overrides:
findMapDeserializerin classDeserializers.Base- Parameters:
type- Type ofMapinstances to deserializeconfig- Configuration in effectbeanDesc- Definition of the enumeration type that contains class annotations and other information typically needed for building deserializerskeyDeserializer- 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 usingResolvableDeserializercallback)- 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:DeserializersMethod called to locate serializer for specified "Map-like" type (one that acts likeMapbut 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
KeyDeserializermay 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 (usingResolvableDeserializer.resolve(com.fasterxml.jackson.databind.DeserializationContext)).- Specified by:
findMapLikeDeserializerin interfaceDeserializers- Overrides:
findMapLikeDeserializerin classDeserializers.Base- Parameters:
type- Type ofMapinstances to deserializeconfig- Configuration in effectbeanDesc- Definition of the enumeration type that contains class annotations and other information typically needed for building deserializerskeyDeserializer- 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 usingResolvableDeserializercallback)- Returns:
- Deserializer to use for the type; or null if this provider does not know how to construct it
- Throws:
JsonMappingException
-
hasDeserializerFor
public boolean hasDeserializerFor(DeserializationConfig config, java.lang.Class<?> valueType)
Description copied from interface:DeserializersMethod that may be called to check whether this deserializer provider would provide deserializer for values of given type, without attempting to construct (and possibly fail in some cases) actual deserializer. Mostly needed to support validation of polymorphic type ids.Note: implementations should take care NOT to claim supporting types that they do not recognize as this could to incorrect assumption of safe support by caller.
Method added in Jackson 2.13 now that Java 8 default implementations are available for use with interface definitions.
- Specified by:
hasDeserializerForin interfaceDeserializers
-
-