org.codehaus.jackson.map.deser
Class BeanDeserializerFactory

java.lang.Object
  extended by org.codehaus.jackson.map.DeserializerFactory
      extended by org.codehaus.jackson.map.deser.BasicDeserializerFactory
          extended by org.codehaus.jackson.map.deser.BeanDeserializerFactory
Direct Known Subclasses:
CustomDeserializerFactory

public class BeanDeserializerFactory
extends BasicDeserializerFactory

Concrete deserializer factory class that adds full Bean deserializer construction logic using class introspection.

Since there is no caching, this factory is stateless and a globally shared singleton instance (instance) can be used by DeserializerProviders).


Nested Class Summary
static class BeanDeserializerFactory.ConfigImpl
          Standard configuration settings container class implementation.
 
Nested classes/interfaces inherited from class org.codehaus.jackson.map.DeserializerFactory
DeserializerFactory.Config
 
Field Summary
protected  DeserializerFactory.Config _factoryConfig
          Configuration settings for this factory; immutable instance (just like this factory), new version created via copy-constructor (fluent-style)
static BeanDeserializerFactory instance
          Globally shareable thread-safe instance which has no additional custom deserializers registered
 
Fields inherited from class org.codehaus.jackson.map.deser.BasicDeserializerFactory
_arrayDeserializers, optionalHandlers
 
Fields inherited from class org.codehaus.jackson.map.DeserializerFactory
NO_DESERIALIZERS
 
Constructor Summary
BeanDeserializerFactory()
          Deprecated. 
BeanDeserializerFactory(DeserializerFactory.Config config)
           
 
Method Summary
protected  void _addDeserializerConstructors(DeserializationConfig config, BasicBeanDescription beanDesc, VisibilityChecker<?> vchecker, AnnotationIntrospector intr, CreatorCollector creators)
           
protected  void _addDeserializerFactoryMethods(DeserializationConfig config, BasicBeanDescription beanDesc, VisibilityChecker<?> vchecker, AnnotationIntrospector intr, CreatorCollector creators)
           
protected  JsonDeserializer<?> _findCustomArrayDeserializer(ArrayType type, DeserializationConfig config, DeserializerProvider provider, BeanProperty property, TypeDeserializer elementTypeDeserializer, JsonDeserializer<?> elementDeserializer)
           
protected  JsonDeserializer<Object> _findCustomBeanDeserializer(JavaType type, DeserializationConfig config, DeserializerProvider provider, BasicBeanDescription beanDesc, BeanProperty property)
           
protected  JsonDeserializer<?> _findCustomCollectionDeserializer(CollectionType type, DeserializationConfig config, DeserializerProvider provider, BasicBeanDescription beanDesc, BeanProperty property, TypeDeserializer elementTypeDeserializer, JsonDeserializer<?> elementDeserializer)
           
protected  JsonDeserializer<?> _findCustomCollectionLikeDeserializer(CollectionLikeType type, DeserializationConfig config, DeserializerProvider provider, BasicBeanDescription beanDesc, BeanProperty property, TypeDeserializer elementTypeDeserializer, JsonDeserializer<?> elementDeserializer)
           
protected  JsonDeserializer<?> _findCustomEnumDeserializer(Class<?> type, DeserializationConfig config, BasicBeanDescription beanDesc, BeanProperty property)
           
protected  JsonDeserializer<?> _findCustomMapDeserializer(MapType type, DeserializationConfig config, DeserializerProvider provider, BasicBeanDescription beanDesc, BeanProperty property, KeyDeserializer keyDeserializer, TypeDeserializer elementTypeDeserializer, JsonDeserializer<?> elementDeserializer)
           
protected  JsonDeserializer<?> _findCustomMapLikeDeserializer(MapLikeType type, DeserializationConfig config, DeserializerProvider provider, BasicBeanDescription beanDesc, BeanProperty property, KeyDeserializer keyDeserializer, TypeDeserializer elementTypeDeserializer, JsonDeserializer<?> elementDeserializer)
           
protected  JsonDeserializer<?> _findCustomTreeNodeDeserializer(Class<? extends JsonNode> type, DeserializationConfig config, BeanProperty property)
           
protected  boolean _handleSingleArgumentConstructor(DeserializationConfig config, BasicBeanDescription beanDesc, VisibilityChecker<?> vchecker, AnnotationIntrospector intr, CreatorCollector creators, AnnotatedConstructor ctor, boolean isCreator, boolean isVisible)
           
protected  boolean _handleSingleArgumentFactory(DeserializationConfig config, BasicBeanDescription beanDesc, VisibilityChecker<?> vchecker, AnnotationIntrospector intr, CreatorCollector creators, AnnotatedMethod factory, boolean isCreator)
           
protected  JavaType _mapAbstractType2(DeserializationConfig config, JavaType type)
          Method that will find abstract type mapping for specified type, doing a single lookup through registered abstract type resolvers; will not do recursive lookups.
protected  void addBeanProps(DeserializationConfig config, BasicBeanDescription beanDesc, BeanDeserializerBuilder builder)
          Method called to figure out settable properties for the bean deserializer to use.
protected  void addInjectables(DeserializationConfig config, BasicBeanDescription beanDesc, BeanDeserializerBuilder builder)
          Method called locate all members used for value injection (if any), constructor ValueInjector instances, and add them to builder.
protected  void addReferenceProperties(DeserializationConfig config, BasicBeanDescription beanDesc, BeanDeserializerBuilder builder)
          Method that will find if bean has any managed- or back-reference properties, and if so add them to bean, to be linked during resolution phase.
 JsonDeserializer<Object> buildBeanDeserializer(DeserializationConfig config, JavaType type, BasicBeanDescription beanDesc, BeanProperty property)
          Method that is to actually build a bean deserializer instance.
 JsonDeserializer<Object> buildThrowableDeserializer(DeserializationConfig config, JavaType type, BasicBeanDescription beanDesc, BeanProperty property)
           
protected  SettableAnyProperty constructAnySetter(DeserializationConfig config, BasicBeanDescription beanDesc, AnnotatedMethod setter)
          Method called to construct fallback SettableAnyProperty for handling unknown bean properties, given a method that has been designated as such setter.
protected  BeanDeserializerBuilder constructBeanDeserializerBuilder(BasicBeanDescription beanDesc)
          Overridable method that constructs a BeanDeserializerBuilder which is used to accumulate information needed to create deserializer instance.
protected  CreatorProperty constructCreatorProperty(DeserializationConfig config, BasicBeanDescription 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  ValueInstantiator constructDefaultValueInstantiator(DeserializationConfig config, BasicBeanDescription beanDesc)
          Method that will construct standard default ValueInstantiator using annotations (like @JsonCreator) and visibility rules
protected  SettableBeanProperty constructSettableProperty(DeserializationConfig config, BasicBeanDescription beanDesc, String name, AnnotatedField field)
           
protected  SettableBeanProperty constructSettableProperty(DeserializationConfig config, BasicBeanDescription beanDesc, String name, AnnotatedMethod setter)
          Method that will construct a regular bean property setter using the given setter method.
protected  SettableBeanProperty constructSetterlessProperty(DeserializationConfig config, BasicBeanDescription beanDesc, String name, AnnotatedMethod getter)
          Method that will construct a regular bean property setter using the given setter method.
 JsonDeserializer<Object> createBeanDeserializer(DeserializationConfig config, DeserializerProvider p, JavaType type, BeanProperty property)
          Method that DeserializerProviders call to create a new deserializer for types other than Collections, Maps, arrays and enums.
 KeyDeserializer createKeyDeserializer(DeserializationConfig config, JavaType type, BeanProperty property)
          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.
 ValueInstantiator findValueInstantiator(DeserializationConfig config, BasicBeanDescription beanDesc)
          Value instantiator is created both based on creator annotations, and on optional externally provided instantiators (registered through module interface).
 DeserializerFactory.Config getConfig()
           
protected  boolean isIgnorableType(DeserializationConfig config, BasicBeanDescription beanDesc, Class<?> type, Map<Class<?>,Boolean> ignoredTypes)
          Helper method that will check whether given raw type is marked as always ignorable (for purpose of ignoring properties with type)
protected  boolean isPotentialBeanType(Class<?> type)
          Helper method used to skip processing for types that we know can not be (i.e.
 JavaType mapAbstractType(DeserializationConfig config, JavaType type)
          Method that will find complete abstract type mapping for specified type, doing as many resolution steps as necessary.
protected  JavaType materializeAbstractType(DeserializationConfig config, BasicBeanDescription beanDesc)
           
 DeserializerFactory withConfig(DeserializerFactory.Config config)
          Method used by module registration functionality, to construct a new bean deserializer factory with different configuration settings.
 
Methods inherited from class org.codehaus.jackson.map.deser.BasicDeserializerFactory
constructEnumResolver, createArrayDeserializer, createCollectionDeserializer, createCollectionLikeDeserializer, createEnumDeserializer, createMapDeserializer, createMapLikeDeserializer, createTreeDeserializer, findDeserializerFromAnnotation, findPropertyContentTypeDeserializer, findPropertyTypeDeserializer, findStdBeanDeserializer, findTypeDeserializer, modifyTypeByAnnotation, resolveType
 
Methods inherited from class org.codehaus.jackson.map.DeserializerFactory
withAbstractTypeResolver, withAdditionalDeserializers, withAdditionalKeyDeserializers, withDeserializerModifier, withValueInstantiators
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

instance

public static final BeanDeserializerFactory instance
Globally shareable thread-safe instance which has no additional custom deserializers registered


_factoryConfig

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

Since:
1.7
Constructor Detail

BeanDeserializerFactory

@Deprecated
public BeanDeserializerFactory()
Deprecated. 


BeanDeserializerFactory

public BeanDeserializerFactory(DeserializerFactory.Config config)
Since:
1.7
Method Detail

getConfig

public final DeserializerFactory.Config getConfig()
Specified by:
getConfig in class DeserializerFactory

withConfig

public DeserializerFactory withConfig(DeserializerFactory.Config config)
Method used by module registration functionality, to construct a new bean deserializer factory with different configuration settings.

Specified by:
withConfig in class BasicDeserializerFactory
Since:
1.7

createKeyDeserializer

public KeyDeserializer createKeyDeserializer(DeserializationConfig config,
                                             JavaType type,
                                             BeanProperty property)
                                      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.

Overrides:
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

_findCustomArrayDeserializer

protected JsonDeserializer<?> _findCustomArrayDeserializer(ArrayType type,
                                                           DeserializationConfig config,
                                                           DeserializerProvider provider,
                                                           BeanProperty property,
                                                           TypeDeserializer elementTypeDeserializer,
                                                           JsonDeserializer<?> elementDeserializer)
                                                    throws JsonMappingException
Specified by:
_findCustomArrayDeserializer in class BasicDeserializerFactory
Throws:
JsonMappingException

_findCustomCollectionDeserializer

protected JsonDeserializer<?> _findCustomCollectionDeserializer(CollectionType type,
                                                                DeserializationConfig config,
                                                                DeserializerProvider provider,
                                                                BasicBeanDescription beanDesc,
                                                                BeanProperty property,
                                                                TypeDeserializer elementTypeDeserializer,
                                                                JsonDeserializer<?> elementDeserializer)
                                                         throws JsonMappingException
Specified by:
_findCustomCollectionDeserializer in class BasicDeserializerFactory
Throws:
JsonMappingException

_findCustomCollectionLikeDeserializer

protected JsonDeserializer<?> _findCustomCollectionLikeDeserializer(CollectionLikeType type,
                                                                    DeserializationConfig config,
                                                                    DeserializerProvider provider,
                                                                    BasicBeanDescription beanDesc,
                                                                    BeanProperty property,
                                                                    TypeDeserializer elementTypeDeserializer,
                                                                    JsonDeserializer<?> elementDeserializer)
                                                             throws JsonMappingException
Specified by:
_findCustomCollectionLikeDeserializer in class BasicDeserializerFactory
Throws:
JsonMappingException

_findCustomEnumDeserializer

protected JsonDeserializer<?> _findCustomEnumDeserializer(Class<?> type,
                                                          DeserializationConfig config,
                                                          BasicBeanDescription beanDesc,
                                                          BeanProperty property)
                                                   throws JsonMappingException
Specified by:
_findCustomEnumDeserializer in class BasicDeserializerFactory
Throws:
JsonMappingException

_findCustomMapDeserializer

protected JsonDeserializer<?> _findCustomMapDeserializer(MapType type,
                                                         DeserializationConfig config,
                                                         DeserializerProvider provider,
                                                         BasicBeanDescription beanDesc,
                                                         BeanProperty property,
                                                         KeyDeserializer keyDeserializer,
                                                         TypeDeserializer elementTypeDeserializer,
                                                         JsonDeserializer<?> elementDeserializer)
                                                  throws JsonMappingException
Specified by:
_findCustomMapDeserializer in class BasicDeserializerFactory
Throws:
JsonMappingException

_findCustomMapLikeDeserializer

protected JsonDeserializer<?> _findCustomMapLikeDeserializer(MapLikeType type,
                                                             DeserializationConfig config,
                                                             DeserializerProvider provider,
                                                             BasicBeanDescription beanDesc,
                                                             BeanProperty property,
                                                             KeyDeserializer keyDeserializer,
                                                             TypeDeserializer elementTypeDeserializer,
                                                             JsonDeserializer<?> elementDeserializer)
                                                      throws JsonMappingException
Specified by:
_findCustomMapLikeDeserializer in class BasicDeserializerFactory
Throws:
JsonMappingException

_findCustomTreeNodeDeserializer

protected JsonDeserializer<?> _findCustomTreeNodeDeserializer(Class<? extends JsonNode> type,
                                                              DeserializationConfig config,
                                                              BeanProperty property)
                                                       throws JsonMappingException
Specified by:
_findCustomTreeNodeDeserializer in class BasicDeserializerFactory
Throws:
JsonMappingException

_findCustomBeanDeserializer

protected JsonDeserializer<Object> _findCustomBeanDeserializer(JavaType type,
                                                               DeserializationConfig config,
                                                               DeserializerProvider provider,
                                                               BasicBeanDescription beanDesc,
                                                               BeanProperty property)
                                                        throws JsonMappingException
Throws:
JsonMappingException

mapAbstractType

public JavaType mapAbstractType(DeserializationConfig config,
                                JavaType type)
                         throws JsonMappingException
Method that will find complete abstract type mapping for specified type, doing as many resolution steps as necessary.

Specified by:
mapAbstractType in class BasicDeserializerFactory
Throws:
JsonMappingException

findValueInstantiator

public ValueInstantiator findValueInstantiator(DeserializationConfig config,
                                               BasicBeanDescription 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 BasicDeserializerFactory
Throws:
JsonMappingException

createBeanDeserializer

public JsonDeserializer<Object> createBeanDeserializer(DeserializationConfig config,
                                                       DeserializerProvider p,
                                                       JavaType type,
                                                       BeanProperty property)
                                                throws JsonMappingException
Method that DeserializerProviders call to create a new deserializer for types other than Collections, Maps, arrays and enums.

Specified by:
createBeanDeserializer in class DeserializerFactory
p - Provider that can be called to create deserializers for contained member types
type - Type to be deserialized
Throws:
JsonMappingException

_mapAbstractType2

protected JavaType _mapAbstractType2(DeserializationConfig config,
                                     JavaType type)
                              throws JsonMappingException
Method that will find abstract type mapping for specified type, doing a single lookup through registered abstract type resolvers; will not do recursive lookups.

Throws:
JsonMappingException

materializeAbstractType

protected JavaType materializeAbstractType(DeserializationConfig config,
                                           BasicBeanDescription beanDesc)
                                    throws JsonMappingException
Throws:
JsonMappingException

buildBeanDeserializer

public JsonDeserializer<Object> buildBeanDeserializer(DeserializationConfig config,
                                                      JavaType type,
                                                      BasicBeanDescription beanDesc,
                                                      BeanProperty property)
                                               throws JsonMappingException
Method that is to actually build a bean deserializer instance. All basic sanity checks have been done to know that what we have may be a valid bean type, and that there are no default simple deserializers.

Throws:
JsonMappingException

buildThrowableDeserializer

public JsonDeserializer<Object> buildThrowableDeserializer(DeserializationConfig config,
                                                           JavaType type,
                                                           BasicBeanDescription beanDesc,
                                                           BeanProperty property)
                                                    throws JsonMappingException
Throws:
JsonMappingException

constructBeanDeserializerBuilder

protected BeanDeserializerBuilder constructBeanDeserializerBuilder(BasicBeanDescription beanDesc)
Overridable method that constructs a BeanDeserializerBuilder which is used to accumulate information needed to create deserializer instance.

Since:
1.7

constructDefaultValueInstantiator

protected ValueInstantiator constructDefaultValueInstantiator(DeserializationConfig config,
                                                              BasicBeanDescription beanDesc)
                                                       throws JsonMappingException
Method that will construct standard default ValueInstantiator using annotations (like @JsonCreator) and visibility rules

Throws:
JsonMappingException
Since:
1.9

_addDeserializerConstructors

protected void _addDeserializerConstructors(DeserializationConfig config,
                                            BasicBeanDescription beanDesc,
                                            VisibilityChecker<?> vchecker,
                                            AnnotationIntrospector intr,
                                            CreatorCollector creators)
                                     throws JsonMappingException
Throws:
JsonMappingException

_handleSingleArgumentConstructor

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

_addDeserializerFactoryMethods

protected void _addDeserializerFactoryMethods(DeserializationConfig config,
                                              BasicBeanDescription beanDesc,
                                              VisibilityChecker<?> vchecker,
                                              AnnotationIntrospector intr,
                                              CreatorCollector creators)
                                       throws JsonMappingException
Throws:
JsonMappingException

_handleSingleArgumentFactory

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

constructCreatorProperty

protected CreatorProperty constructCreatorProperty(DeserializationConfig config,
                                                   BasicBeanDescription 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

addBeanProps

protected void addBeanProps(DeserializationConfig config,
                            BasicBeanDescription beanDesc,
                            BeanDeserializerBuilder builder)
                     throws JsonMappingException
Method called to figure out settable properties for the bean deserializer to use.

Note: designed to be overridable, and effort is made to keep interface similar between versions.

Throws:
JsonMappingException

addReferenceProperties

protected void addReferenceProperties(DeserializationConfig config,
                                      BasicBeanDescription beanDesc,
                                      BeanDeserializerBuilder builder)
                               throws JsonMappingException
Method that will find if bean has any managed- or back-reference properties, and if so add them to bean, to be linked during resolution phase.

Throws:
JsonMappingException
Since:
1.6

addInjectables

protected void addInjectables(DeserializationConfig config,
                              BasicBeanDescription beanDesc,
                              BeanDeserializerBuilder builder)
                       throws JsonMappingException
Method called locate all members used for value injection (if any), constructor ValueInjector instances, and add them to builder.

Throws:
JsonMappingException
Since:
1.9

constructAnySetter

protected SettableAnyProperty constructAnySetter(DeserializationConfig config,
                                                 BasicBeanDescription beanDesc,
                                                 AnnotatedMethod setter)
                                          throws JsonMappingException
Method called to construct fallback SettableAnyProperty for handling unknown bean properties, given a method that has been designated as such setter.

Throws:
JsonMappingException

constructSettableProperty

protected SettableBeanProperty constructSettableProperty(DeserializationConfig config,
                                                         BasicBeanDescription beanDesc,
                                                         String name,
                                                         AnnotatedMethod setter)
                                                  throws JsonMappingException
Method that will construct a regular bean property setter using the given setter method.

Parameters:
setter - Method to use to set property value; or null if none. Null only for "setterless" properties
Returns:
Property constructed, if any; or null to indicate that there should be no property based on given definitions.
Throws:
JsonMappingException

constructSettableProperty

protected SettableBeanProperty constructSettableProperty(DeserializationConfig config,
                                                         BasicBeanDescription beanDesc,
                                                         String name,
                                                         AnnotatedField field)
                                                  throws JsonMappingException
Throws:
JsonMappingException

constructSetterlessProperty

protected SettableBeanProperty constructSetterlessProperty(DeserializationConfig config,
                                                           BasicBeanDescription beanDesc,
                                                           String name,
                                                           AnnotatedMethod getter)
                                                    throws JsonMappingException
Method that will construct a regular bean property setter using the given setter method.

Parameters:
getter - Method to use to get property value to modify, null if none. Non-null for "setterless" properties.
Throws:
JsonMappingException

isPotentialBeanType

protected boolean isPotentialBeanType(Class<?> type)
Helper method used to skip processing for types that we know can not be (i.e. are never consider to be) beans: things like primitives, Arrays, Enums, and proxy types.

Note that usually we shouldn't really be getting these sort of types anyway; but better safe than sorry.


isIgnorableType

protected boolean isIgnorableType(DeserializationConfig config,
                                  BasicBeanDescription beanDesc,
                                  Class<?> type,
                                  Map<Class<?>,Boolean> ignoredTypes)
Helper method that will check whether given raw type is marked as always ignorable (for purpose of ignoring properties with type)