com.fasterxml.jackson.databind.deser
Class BasicDeserializerFactory

java.lang.Object
  extended by com.fasterxml.jackson.databind.deser.DeserializerFactory
      extended by com.fasterxml.jackson.databind.deser.BasicDeserializerFactory
Direct Known Subclasses:
BeanDeserializerFactory

public abstract class BasicDeserializerFactory
extends DeserializerFactory

Abstract factory base class that can provide deserializers for standard JDK classes, including collection classes and simple heuristics for "upcasting" commmon collection interface types (such as Collection).

Since all simple deserializers are eagerly instantiated, and there is no additional introspection or customizability of these types, this factory is stateless.


Field Summary
protected static HashMap<JavaType,JsonDeserializer<Object>> _arrayDeserializers
          Also special array deserializers for primitive array types.
protected  DeserializerFactoryConfig _factoryConfig
          Configuration settings for this factory; immutable instance (just like this factory), new version created via copy-constructor (fluent-style)
protected static HashMap<JavaType,KeyDeserializer> _keyDeserializers
          Set of available key deserializers is currently limited to standard types; and all known instances are storing in this map.
protected static HashMap<ClassKey,JsonDeserializer<Object>> _simpleDeserializers
          We will pre-create serializers for common non-structured (that is things other than Collection, Map or array) types.
protected  OptionalHandlerFactory optionalHandlers
          To support external/optional deserializers, we'll use a helper class
 
Fields inherited from class com.fasterxml.jackson.databind.deser.DeserializerFactory
NO_DESERIALIZERS
 
Constructor Summary
protected BasicDeserializerFactory(DeserializerFactoryConfig config)
           
 
Method Summary
protected  void _addDeserializerConstructors(DeserializationContext ctxt, BeanDescription beanDesc, VisibilityChecker<?> vchecker, AnnotationIntrospector intr, CreatorCollector creators)
           
protected  void _addDeserializerFactoryMethods(DeserializationContext ctxt, BeanDescription beanDesc, VisibilityChecker<?> vchecker, AnnotationIntrospector intr, CreatorCollector creators)
           
protected  ValueInstantiator _constructDefaultValueInstantiator(DeserializationContext ctxt, BeanDescription beanDesc)
          Method that will construct standard default ValueInstantiator using annotations (like @JsonCreator) and visibility rules
protected  JsonDeserializer<?> _findCustomArrayDeserializer(ArrayType type, DeserializationConfig config, BeanDescription beanDesc, TypeDeserializer elementTypeDeserializer, JsonDeserializer<?> elementDeserializer)
           
protected  JsonDeserializer<?> _findCustomCollectionDeserializer(CollectionType type, DeserializationConfig config, BeanDescription beanDesc, TypeDeserializer elementTypeDeserializer, JsonDeserializer<?> elementDeserializer)
           
protected  JsonDeserializer<?> _findCustomCollectionLikeDeserializer(CollectionLikeType type, DeserializationConfig config, BeanDescription beanDesc, TypeDeserializer elementTypeDeserializer, JsonDeserializer<?> elementDeserializer)
           
protected  JsonDeserializer<?> _findCustomEnumDeserializer(Class<?> type, DeserializationConfig config, BeanDescription beanDesc)
           
protected  JsonDeserializer<?> _findCustomMapDeserializer(MapType type, DeserializationConfig config, BeanDescription beanDesc, KeyDeserializer keyDeserializer, TypeDeserializer elementTypeDeserializer, JsonDeserializer<?> elementDeserializer)
           
protected  JsonDeserializer<?> _findCustomMapLikeDeserializer(MapLikeType type, DeserializationConfig config, BeanDescription beanDesc, KeyDeserializer keyDeserializer, TypeDeserializer elementTypeDeserializer, JsonDeserializer<?> elementDeserializer)
           
protected  JsonDeserializer<?> _findCustomTreeNodeDeserializer(Class<? extends JsonNode> type, DeserializationConfig config, BeanDescription beanDesc)
           
protected  AnnotatedMethod _findJsonValueFor(DeserializationConfig config, JavaType enumType)
           
protected  boolean _handleSingleArgumentConstructor(DeserializationContext ctxt, BeanDescription beanDesc, VisibilityChecker<?> vchecker, AnnotationIntrospector intr, CreatorCollector creators, AnnotatedConstructor ctor, boolean isCreator, boolean isVisible)
           
protected  boolean _handleSingleArgumentFactory(DeserializationConfig config, BeanDescription beanDesc, VisibilityChecker<?> vchecker, AnnotationIntrospector intr, CreatorCollector creators, AnnotatedMethod factory, boolean isCreator)
           
 ValueInstantiator _valueInstantiatorInstance(DeserializationConfig config, Annotated annotated, Object instDef)
           
protected  CreatorProperty constructCreatorProperty(DeserializationContext ctxt, BeanDescription beanDesc, String name, int index, AnnotatedParameter param, Object injectableValueId)
          Method that will construct a property object that represents a logical property passed via Creator (constructor or static factory method)
protected  EnumResolver<?> constructEnumResolver(Class<?> enumClass, DeserializationConfig config, AnnotatedMethod jsonValueMethod)
           
 JsonDeserializer<?> createArrayDeserializer(DeserializationContext ctxt, ArrayType type, BeanDescription beanDesc)
          Method called to create (or, for completely immutable deserializers, reuse) a deserializer that can convert JSON content into values of specified Java type.
 JsonDeserializer<?> createCollectionDeserializer(DeserializationContext ctxt, CollectionType type, BeanDescription beanDesc)
           
 JsonDeserializer<?> createCollectionLikeDeserializer(DeserializationContext ctxt, CollectionLikeType type, BeanDescription beanDesc)
           
 JsonDeserializer<?> createEnumDeserializer(DeserializationContext ctxt, JavaType type, BeanDescription beanDesc)
          Factory method for constructing serializers of Enum types.
 KeyDeserializer createKeyDeserializer(DeserializationContext ctxt, JavaType type)
          Method called to find if factory knows how to create a key deserializer for specified type; currently this means checking if a module has registered possible deserializers.
 JsonDeserializer<?> createMapDeserializer(DeserializationContext ctxt, MapType type, BeanDescription beanDesc)
           
 JsonDeserializer<?> createMapLikeDeserializer(DeserializationContext ctxt, MapLikeType type, BeanDescription beanDesc)
           
 JsonDeserializer<?> createTreeDeserializer(DeserializationConfig config, JavaType nodeType, BeanDescription beanDesc)
          Method called to create and return a deserializer that can construct JsonNode(s) from JSON content.
protected  JsonDeserializer<Object> findDeserializerFromAnnotation(DeserializationContext ctxt, Annotated ann)
          Helper method called to check if a class or method has annotation that tells which class to use for deserialization.
 TypeDeserializer findPropertyContentTypeDeserializer(DeserializationConfig config, JavaType containerType, AnnotatedMember propertyEntity)
          Method called to find and create a type information deserializer for values of given container (list, array, map) property, if one is needed.
 TypeDeserializer findPropertyTypeDeserializer(DeserializationConfig config, JavaType baseType, AnnotatedMember annotated)
          Method called to create a type information deserializer for values of given non-container property, if one is needed.
 TypeDeserializer findTypeDeserializer(DeserializationConfig config, JavaType baseType)
          Method called to find and create a type information deserializer for given base type, if one is needed.
 ValueInstantiator findValueInstantiator(DeserializationContext ctxt, BeanDescription beanDesc)
          Value instantiator is created both based on creator annotations, and on optional externally provided instantiators (registered through module interface).
 JavaType mapAbstractType(DeserializationConfig config, JavaType type)
          Method that can be called to try to resolve an abstract type (interface, abstract class) into a concrete type, or at least something "more concrete" (abstract class instead of interface).
protected
<T extends JavaType>
T
modifyTypeByAnnotation(DeserializationContext ctxt, Annotated a, T type)
          Method called to see if given method has annotations that indicate a more specific type than what the argument specifies.
protected  JavaType resolveType(DeserializationContext ctxt, BeanDescription beanDesc, JavaType type, AnnotatedMember member)
          Helper method used to resolve method return types and field types.
 DeserializerFactory withAbstractTypeResolver(AbstractTypeResolver resolver)
          Convenience method for creating a new factory instance with additional AbstractTypeResolver.
 DeserializerFactory withAdditionalDeserializers(Deserializers additional)
          Convenience method for creating a new factory instance with additional deserializer provider.
 DeserializerFactory withAdditionalKeyDeserializers(KeyDeserializers additional)
          Convenience method for creating a new factory instance with additional KeyDeserializers.
protected abstract  DeserializerFactory withConfig(DeserializerFactoryConfig config)
           
 DeserializerFactory withDeserializerModifier(BeanDeserializerModifier modifier)
          Convenience method for creating a new factory instance with additional BeanDeserializerModifier.
 DeserializerFactory withValueInstantiators(ValueInstantiators instantiators)
          Convenience method for creating a new factory instance with additional ValueInstantiators.
 
Methods inherited from class com.fasterxml.jackson.databind.deser.DeserializerFactory
createBeanDeserializer, createBuilderBasedDeserializer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_simpleDeserializers

protected static final HashMap<ClassKey,JsonDeserializer<Object>> _simpleDeserializers
We will pre-create serializers for common non-structured (that is things other than Collection, Map or array) types. These need not go through factory.


_arrayDeserializers

protected static final HashMap<JavaType,JsonDeserializer<Object>> _arrayDeserializers
Also special array deserializers for primitive array types.


_keyDeserializers

protected static final HashMap<JavaType,KeyDeserializer> _keyDeserializers
Set of available key deserializers is currently limited to standard types; and all known instances are storing in this map.


optionalHandlers

protected OptionalHandlerFactory optionalHandlers
To support external/optional deserializers, we'll use a helper class


_factoryConfig

protected final DeserializerFactoryConfig _factoryConfig
Configuration settings for this factory; immutable instance (just like this factory), new version created via copy-constructor (fluent-style)

Constructor Detail

BasicDeserializerFactory

protected BasicDeserializerFactory(DeserializerFactoryConfig config)
Method Detail

withConfig

protected abstract DeserializerFactory withConfig(DeserializerFactoryConfig config)

withAdditionalDeserializers

public final DeserializerFactory withAdditionalDeserializers(Deserializers additional)
Convenience method for creating a new factory instance with additional deserializer provider.

Specified by:
withAdditionalDeserializers in class DeserializerFactory

withAdditionalKeyDeserializers

public final DeserializerFactory withAdditionalKeyDeserializers(KeyDeserializers additional)
Convenience method for creating a new factory instance with additional KeyDeserializers.

Specified by:
withAdditionalKeyDeserializers in class DeserializerFactory

withDeserializerModifier

public final DeserializerFactory withDeserializerModifier(BeanDeserializerModifier modifier)
Convenience method for creating a new factory instance with additional BeanDeserializerModifier.

Specified by:
withDeserializerModifier in class DeserializerFactory

withAbstractTypeResolver

public final DeserializerFactory withAbstractTypeResolver(AbstractTypeResolver resolver)
Convenience method for creating a new factory instance with additional AbstractTypeResolver.

Specified by:
withAbstractTypeResolver in class DeserializerFactory

withValueInstantiators

public final DeserializerFactory withValueInstantiators(ValueInstantiators instantiators)
Convenience method for creating a new factory instance with additional ValueInstantiators.

Specified by:
withValueInstantiators in class DeserializerFactory

mapAbstractType

public JavaType mapAbstractType(DeserializationConfig config,
                                JavaType type)
                         throws JsonMappingException
Description copied from class: DeserializerFactory
Method that can be called to try to resolve an abstract type (interface, abstract class) into a concrete type, or at least something "more concrete" (abstract class instead of interface). Will either return passed type, or a more specific type.

Specified by:
mapAbstractType in class DeserializerFactory
Throws:
JsonMappingException

findValueInstantiator

public ValueInstantiator findValueInstantiator(DeserializationContext ctxt,
                                               BeanDescription beanDesc)
                                        throws JsonMappingException
Value instantiator is created both based on creator annotations, and on optional externally provided instantiators (registered through module interface).

Specified by:
findValueInstantiator in class DeserializerFactory
Throws:
JsonMappingException

_constructDefaultValueInstantiator

protected ValueInstantiator _constructDefaultValueInstantiator(DeserializationContext ctxt,
                                                               BeanDescription beanDesc)
                                                        throws JsonMappingException
Method that will construct standard default ValueInstantiator using annotations (like @JsonCreator) and visibility rules

Throws:
JsonMappingException

_valueInstantiatorInstance

public ValueInstantiator _valueInstantiatorInstance(DeserializationConfig config,
                                                    Annotated annotated,
                                                    Object instDef)
                                             throws JsonMappingException
Throws:
JsonMappingException

_addDeserializerConstructors

protected void _addDeserializerConstructors(DeserializationContext ctxt,
                                            BeanDescription beanDesc,
                                            VisibilityChecker<?> vchecker,
                                            AnnotationIntrospector intr,
                                            CreatorCollector creators)
                                     throws JsonMappingException
Throws:
JsonMappingException

_handleSingleArgumentConstructor

protected boolean _handleSingleArgumentConstructor(DeserializationContext ctxt,
                                                   BeanDescription beanDesc,
                                                   VisibilityChecker<?> vchecker,
                                                   AnnotationIntrospector intr,
                                                   CreatorCollector creators,
                                                   AnnotatedConstructor ctor,
                                                   boolean isCreator,
                                                   boolean isVisible)
                                            throws JsonMappingException
Throws:
JsonMappingException

_addDeserializerFactoryMethods

protected void _addDeserializerFactoryMethods(DeserializationContext ctxt,
                                              BeanDescription beanDesc,
                                              VisibilityChecker<?> vchecker,
                                              AnnotationIntrospector intr,
                                              CreatorCollector creators)
                                       throws JsonMappingException
Throws:
JsonMappingException

_handleSingleArgumentFactory

protected boolean _handleSingleArgumentFactory(DeserializationConfig config,
                                               BeanDescription beanDesc,
                                               VisibilityChecker<?> vchecker,
                                               AnnotationIntrospector intr,
                                               CreatorCollector creators,
                                               AnnotatedMethod factory,
                                               boolean isCreator)
                                        throws JsonMappingException
Throws:
JsonMappingException

constructCreatorProperty

protected CreatorProperty constructCreatorProperty(DeserializationContext ctxt,
                                                   BeanDescription beanDesc,
                                                   String name,
                                                   int index,
                                                   AnnotatedParameter param,
                                                   Object injectableValueId)
                                            throws JsonMappingException
Method that will construct a property object that represents a logical property passed via Creator (constructor or static factory method)

Throws:
JsonMappingException

createArrayDeserializer

public JsonDeserializer<?> createArrayDeserializer(DeserializationContext ctxt,
                                                   ArrayType type,
                                                   BeanDescription beanDesc)
                                            throws JsonMappingException
Description copied from class: DeserializerFactory
Method called to create (or, for completely immutable deserializers, reuse) a deserializer that can convert JSON content into values of specified Java type.

Specified by:
createArrayDeserializer in class DeserializerFactory
type - Type to be deserialized
Throws:
JsonMappingException

_findCustomArrayDeserializer

protected JsonDeserializer<?> _findCustomArrayDeserializer(ArrayType type,
                                                           DeserializationConfig config,
                                                           BeanDescription beanDesc,
                                                           TypeDeserializer elementTypeDeserializer,
                                                           JsonDeserializer<?> elementDeserializer)
                                                    throws JsonMappingException
Throws:
JsonMappingException

createCollectionDeserializer

public JsonDeserializer<?> createCollectionDeserializer(DeserializationContext ctxt,
                                                        CollectionType type,
                                                        BeanDescription beanDesc)
                                                 throws JsonMappingException
Specified by:
createCollectionDeserializer in class DeserializerFactory
Throws:
JsonMappingException

createCollectionLikeDeserializer

public JsonDeserializer<?> createCollectionLikeDeserializer(DeserializationContext ctxt,
                                                            CollectionLikeType type,
                                                            BeanDescription beanDesc)
                                                     throws JsonMappingException
Specified by:
createCollectionLikeDeserializer in class DeserializerFactory
Throws:
JsonMappingException

_findCustomCollectionDeserializer

protected JsonDeserializer<?> _findCustomCollectionDeserializer(CollectionType type,
                                                                DeserializationConfig config,
                                                                BeanDescription beanDesc,
                                                                TypeDeserializer elementTypeDeserializer,
                                                                JsonDeserializer<?> elementDeserializer)
                                                         throws JsonMappingException
Throws:
JsonMappingException

_findCustomCollectionLikeDeserializer

protected JsonDeserializer<?> _findCustomCollectionLikeDeserializer(CollectionLikeType type,
                                                                    DeserializationConfig config,
                                                                    BeanDescription beanDesc,
                                                                    TypeDeserializer elementTypeDeserializer,
                                                                    JsonDeserializer<?> elementDeserializer)
                                                             throws JsonMappingException
Throws:
JsonMappingException

createMapDeserializer

public JsonDeserializer<?> createMapDeserializer(DeserializationContext ctxt,
                                                 MapType type,
                                                 BeanDescription beanDesc)
                                          throws JsonMappingException
Specified by:
createMapDeserializer in class DeserializerFactory
Throws:
JsonMappingException

createMapLikeDeserializer

public JsonDeserializer<?> createMapLikeDeserializer(DeserializationContext ctxt,
                                                     MapLikeType type,
                                                     BeanDescription beanDesc)
                                              throws JsonMappingException
Specified by:
createMapLikeDeserializer in class DeserializerFactory
Throws:
JsonMappingException

_findCustomMapDeserializer

protected JsonDeserializer<?> _findCustomMapDeserializer(MapType type,
                                                         DeserializationConfig config,
                                                         BeanDescription beanDesc,
                                                         KeyDeserializer keyDeserializer,
                                                         TypeDeserializer elementTypeDeserializer,
                                                         JsonDeserializer<?> elementDeserializer)
                                                  throws JsonMappingException
Throws:
JsonMappingException

_findCustomMapLikeDeserializer

protected JsonDeserializer<?> _findCustomMapLikeDeserializer(MapLikeType type,
                                                             DeserializationConfig config,
                                                             BeanDescription beanDesc,
                                                             KeyDeserializer keyDeserializer,
                                                             TypeDeserializer elementTypeDeserializer,
                                                             JsonDeserializer<?> elementDeserializer)
                                                      throws JsonMappingException
Throws:
JsonMappingException

createEnumDeserializer

public JsonDeserializer<?> createEnumDeserializer(DeserializationContext ctxt,
                                                  JavaType type,
                                                  BeanDescription beanDesc)
                                           throws JsonMappingException
Factory method for constructing serializers of Enum types.

Specified by:
createEnumDeserializer in class DeserializerFactory
Throws:
JsonMappingException

_findCustomEnumDeserializer

protected JsonDeserializer<?> _findCustomEnumDeserializer(Class<?> type,
                                                          DeserializationConfig config,
                                                          BeanDescription beanDesc)
                                                   throws JsonMappingException
Throws:
JsonMappingException

createTreeDeserializer

public JsonDeserializer<?> createTreeDeserializer(DeserializationConfig config,
                                                  JavaType nodeType,
                                                  BeanDescription beanDesc)
                                           throws JsonMappingException
Description copied from class: DeserializerFactory
Method called to create and return a deserializer that can construct JsonNode(s) from JSON content.

Specified by:
createTreeDeserializer in class DeserializerFactory
Throws:
JsonMappingException

_findCustomTreeNodeDeserializer

protected JsonDeserializer<?> _findCustomTreeNodeDeserializer(Class<? extends JsonNode> type,
                                                              DeserializationConfig config,
                                                              BeanDescription beanDesc)
                                                       throws JsonMappingException
Throws:
JsonMappingException

findTypeDeserializer

public TypeDeserializer findTypeDeserializer(DeserializationConfig config,
                                             JavaType baseType)
                                      throws JsonMappingException
Description copied from class: DeserializerFactory
Method called to find and create a type information deserializer for given base type, if one is needed. If not needed (no polymorphic handling configured for type), should return null.

Note that this method is usually only directly called for values of container (Collection, array, Map) types and root values, but not for bean property values.

Specified by:
findTypeDeserializer in class DeserializerFactory
baseType - Declared base type of the value to deserializer (actual deserializer type will be this type or its subtype)
Returns:
Type deserializer to use for given base type, if one is needed; null if not.
Throws:
JsonMappingException

createKeyDeserializer

public KeyDeserializer createKeyDeserializer(DeserializationContext ctxt,
                                             JavaType type)
                                      throws JsonMappingException
Description copied from class: DeserializerFactory
Method called to find if factory knows how to create a key deserializer for specified type; currently this means checking if a module has registered possible deserializers.

Specified by:
createKeyDeserializer in class DeserializerFactory
Returns:
Key deserializer to use for specified type, if one found; null if not (and default key deserializer should be used)
Throws:
JsonMappingException

findPropertyTypeDeserializer

public TypeDeserializer findPropertyTypeDeserializer(DeserializationConfig config,
                                                     JavaType baseType,
                                                     AnnotatedMember annotated)
                                              throws JsonMappingException
Method called to create a type information deserializer for values of given non-container property, if one is needed. If not needed (no polymorphic handling configured for property), should return null.

Note that this method is only called for non-container bean properties, and not for values in container types or root values (or container properties)

Parameters:
baseType - Declared base type of the value to deserializer (actual deserializer type will be this type or its subtype)
Returns:
Type deserializer to use for given base type, if one is needed; null if not.
Throws:
JsonMappingException

findPropertyContentTypeDeserializer

public TypeDeserializer findPropertyContentTypeDeserializer(DeserializationConfig config,
                                                            JavaType containerType,
                                                            AnnotatedMember propertyEntity)
                                                     throws JsonMappingException
Method called to find and create a type information deserializer for values of given container (list, array, map) property, if one is needed. If not needed (no polymorphic handling configured for property), should return null.

Note that this method is only called for container bean properties, and not for values in container types or root values (or non-container properties)

Parameters:
containerType - Type of property; must be a container type
propertyEntity - Field or method that contains container property
Throws:
JsonMappingException

findDeserializerFromAnnotation

protected JsonDeserializer<Object> findDeserializerFromAnnotation(DeserializationContext ctxt,
                                                                  Annotated ann)
                                                           throws JsonMappingException
Helper method called to check if a class or method has annotation that tells which class to use for deserialization. Returns null if no such annotation found.

Throws:
JsonMappingException

modifyTypeByAnnotation

protected <T extends JavaType> T modifyTypeByAnnotation(DeserializationContext ctxt,
                                                        Annotated a,
                                                        T type)
                                             throws JsonMappingException
Method called to see if given method has annotations that indicate a more specific type than what the argument specifies. If annotations are present, they must specify compatible Class; instance of which can be assigned using the method. This means that the Class has to be raw class of type, or its sub-class (or, implementing class if original Class instance is an interface).

Parameters:
a - Method or field that the type is associated with
type - Type of field, or the setter argument
Returns:
Original type if no annotations are present; or a more specific type derived from it if type annotation(s) was found
Throws:
JsonMappingException - if invalid annotation is found

resolveType

protected JavaType resolveType(DeserializationContext ctxt,
                               BeanDescription beanDesc,
                               JavaType type,
                               AnnotatedMember member)
                        throws JsonMappingException
Helper method used to resolve method return types and field types. The main trick here is that the containing bean may have type variable binding information (when deserializing using generic type passed as type reference), which is needed in some cases.

Throws:
JsonMappingException

constructEnumResolver

protected EnumResolver<?> constructEnumResolver(Class<?> enumClass,
                                                DeserializationConfig config,
                                                AnnotatedMethod jsonValueMethod)

_findJsonValueFor

protected AnnotatedMethod _findJsonValueFor(DeserializationConfig config,
                                            JavaType enumType)


Copyright © 2012 fasterxml.com. All Rights Reserved.