DeserializerFactory (Jackson JSON Processor)
Date: 2013-07-14

org.codehaus.jackson.map

## Class DeserializerFactory

- java.lang.Object
- - org.codehaus.jackson.map.DeserializerFactory

- Direct Known Subclasses:
    BasicDeserializerFactory

      public abstract class DeserializerFactory
      extends Object

  Abstract class that defines API used by `DeserializerProvider` to obtain actual `JsonDeserializer` instances from multiple distinct factories.

  Since there are multiple broad categories of deserializers, there are multiple factory methods:

  - For JSON "Array" type, we need 2 methods: one to deal with expected Java arrays (`createArrayDeserializer(org.codehaus.jackson.map.DeserializationConfig, org.codehaus.jackson.map.DeserializerProvider, org.codehaus.jackson.map.type.ArrayType, org.codehaus.jackson.map.BeanProperty)`) and the other for other Java containers like `List`s and `Set`s (`createCollectionDeserializer(DeserializationConfig, DeserializerProvider, CollectionType, BeanProperty)`)
  - For JSON "Object" type, we need 2 methods: one to deal with expected Java `Map`s (`createMapDeserializer(org.codehaus.jackson.map.DeserializationConfig, org.codehaus.jackson.map.DeserializerProvider, org.codehaus.jackson.map.type.MapType, org.codehaus.jackson.map.BeanProperty)`), and another for POJOs (`createBeanDeserializer(DeserializationConfig, DeserializerProvider, JavaType, BeanProperty)`.
  - For Tree Model (`JsonNode`) properties there is `createTreeDeserializer(DeserializationConfig, DeserializerProvider, JavaType, BeanProperty)`
  - For enumerated types (`Enum`) there is `createEnumDeserializer(DeserializationConfig, DeserializerProvider, JavaType, BeanProperty)`
  - For all other types, `createBeanDeserializer(DeserializationConfig, DeserializerProvider, JavaType, BeanProperty)` is used.

  All above methods take 2 type arguments, except for the first one which takes just a single argument.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `DeserializerFactory.Config` Configuration settings container class for bean deserializer factory

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected static Deserializers[]` | `NO_DESERIALIZERS`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DeserializerFactory()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `abstract JsonDeserializer<?>` | `createArrayDeserializer(DeserializationConfig config, DeserializerProvider p, ArrayType type, BeanProperty property)` Method called to create (or, for completely immutable deserializers, reuse) a deserializer that can convert JSON content into values of specified Java type.
    `abstract JsonDeserializer<Object>` | `createBeanDeserializer(DeserializationConfig config, DeserializerProvider p, JavaType type, BeanProperty property)` Method called to create (or, for completely immutable deserializers, reuse) a deserializer that can convert JSON content into values of specified Java "bean" (POJO) type.
    `abstract JsonDeserializer<?>` | `createCollectionDeserializer(DeserializationConfig config, DeserializerProvider p, CollectionType type, BeanProperty property)`
    `abstract JsonDeserializer<?>` | `createCollectionLikeDeserializer(DeserializationConfig config, DeserializerProvider p, CollectionLikeType type, BeanProperty property)`
    `abstract JsonDeserializer<?>` | `createEnumDeserializer(DeserializationConfig config, DeserializerProvider p, JavaType type, BeanProperty property)`
    `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.
    `abstract JsonDeserializer<?>` | `createMapDeserializer(DeserializationConfig config, DeserializerProvider p, MapType type, BeanProperty property)`
    `abstract JsonDeserializer<?>` | `createMapLikeDeserializer(DeserializationConfig config, DeserializerProvider p, MapLikeType type, BeanProperty property)`
    `abstract JsonDeserializer<?>` | `createTreeDeserializer(DeserializationConfig config, DeserializerProvider p, JavaType type, BeanProperty property)` Method called to create and return a deserializer that can construct JsonNode(s) from JSON content.
    `TypeDeserializer` | `findTypeDeserializer(DeserializationConfig config, JavaType baseType, BeanProperty property)` Method called to find and create a type information deserializer for given base type, if one is needed.
    `abstract ValueInstantiator` | `findValueInstantiator(DeserializationConfig config, BasicBeanDescription beanDesc)` Method that is to find all creators (constructors, factory methods) for the bean type to deserialize.
    `abstract DeserializerFactory.Config` | `getConfig()`
    `abstract 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).
    `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`.
    `abstract DeserializerFactory` | `withConfig(DeserializerFactory.Config config)` Method used for creating a new instance of this factory, but with different configuration.
    `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 java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### NO_DESERIALIZERS

          protected static final Deserializers[] NO_DESERIALIZERS

  - ### Constructor Detail

    - #### DeserializerFactory

          public DeserializerFactory()

  - ### Method Detail

    - #### getConfig

          public abstract DeserializerFactory.Config getConfig()

      Since:
        1.7

    - #### withConfig

          public abstract DeserializerFactory withConfig(DeserializerFactory.Config config)

      Method used for creating a new instance of this factory, but with different configuration. Reason for specifying factory method (instead of plain constructor) is to allow proper sub-classing of factories.

      Note that custom sub-classes must override implementation of this method, as it usually requires instantiating a new instance of factory type. Check out javadocs for `BeanDeserializerFactory` for more details.

      Since:
        1.7

    - #### withAdditionalDeserializers

          public final DeserializerFactory withAdditionalDeserializers(Deserializers additional)

      Convenience method for creating a new factory instance with additional deserializer provider.
      Since:
        1.7

    - #### withAdditionalKeyDeserializers

          public final DeserializerFactory withAdditionalKeyDeserializers(KeyDeserializers additional)

      Convenience method for creating a new factory instance with additional `KeyDeserializers`.
      Since:
        1.8

    - #### withDeserializerModifier

          public final DeserializerFactory withDeserializerModifier(BeanDeserializerModifier modifier)

      Convenience method for creating a new factory instance with additional `BeanDeserializerModifier`.
      Since:
        1.7

    - #### withAbstractTypeResolver

          public final DeserializerFactory withAbstractTypeResolver(AbstractTypeResolver resolver)

      Convenience method for creating a new factory instance with additional `AbstractTypeResolver`.
      Since:
        1.7

    - #### withValueInstantiators

          public final DeserializerFactory withValueInstantiators(ValueInstantiators instantiators)

      Convenience method for creating a new factory instance with additional `ValueInstantiators`.
      Since:
        1.9

    - #### mapAbstractType

          public abstract JavaType mapAbstractType(DeserializationConfig config,
                                 JavaType type)
                                            throws JsonMappingException

      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.
      Throws:
        `JsonMappingException`
      Since:
        1.9

    - #### findValueInstantiator

          public abstract ValueInstantiator findValueInstantiator(DeserializationConfig config,
                                                BasicBeanDescription beanDesc)
                                                           throws JsonMappingException

      Method that is to find all creators (constructors, factory methods) for the bean type to deserialize.
      Throws:
        `JsonMappingException`
      Since:
        1.9

    - #### createBeanDeserializer

          public abstract JsonDeserializer<Object> createBeanDeserializer(DeserializationConfig config,
                                                        DeserializerProvider p,
                                                        JavaType type,
                                                        BeanProperty property)
                                                                   throws JsonMappingException

      Method called to create (or, for completely immutable deserializers, reuse) a deserializer that can convert JSON content into values of specified Java "bean" (POJO) type. At this point it is known that the type is not otherwise recognized as one of structured types (array, Collection, Map) or a well-known JDK type (enum, primitives/wrappers, String); this method only gets called if other options are exhausted. This also means that this method can be overridden to add support for custom types.
      Parameters:
        `type` - Type to be deserialized
        `p` - Provider that can be called to create deserializers for contained member types
      Throws:
        `JsonMappingException`

    - #### createArrayDeserializer

          public abstract JsonDeserializer<?> createArrayDeserializer(DeserializationConfig config,
                                                    DeserializerProvider p,
                                                    ArrayType type,
                                                    BeanProperty property)
                                                               throws JsonMappingException

      Method called to create (or, for completely immutable deserializers, reuse) a deserializer that can convert JSON content into values of specified Java type.
      Parameters:
        `type` - Type to be deserialized
        `p` - Provider that can be called to create deserializers for contained member types
      Throws:
        `JsonMappingException`

    - #### createCollectionDeserializer

          public abstract JsonDeserializer<?> createCollectionDeserializer(DeserializationConfig config,
                                                         DeserializerProvider p,
                                                         CollectionType type,
                                                         BeanProperty property)
                                                                    throws JsonMappingException

      Throws:
        `JsonMappingException`

    - #### createCollectionLikeDeserializer

          public abstract JsonDeserializer<?> createCollectionLikeDeserializer(DeserializationConfig config,
                                                             DeserializerProvider p,
                                                             CollectionLikeType type,
                                                             BeanProperty property)
                                                                        throws JsonMappingException

      Throws:
        `JsonMappingException`
      Since:
        1.8

    - #### createEnumDeserializer

          public abstract JsonDeserializer<?> createEnumDeserializer(DeserializationConfig config,
                                                   DeserializerProvider p,
                                                   JavaType type,
                                                   BeanProperty property)
                                                              throws JsonMappingException

      Throws:
        `JsonMappingException`

    - #### createMapDeserializer

          public abstract JsonDeserializer<?> createMapDeserializer(DeserializationConfig config,
                                                  DeserializerProvider p,
                                                  MapType type,
                                                  BeanProperty property)
                                                             throws JsonMappingException

      Throws:
        `JsonMappingException`

    - #### createMapLikeDeserializer

          public abstract JsonDeserializer<?> createMapLikeDeserializer(DeserializationConfig config,
                                                      DeserializerProvider p,
                                                      MapLikeType type,
                                                      BeanProperty property)
                                                                 throws JsonMappingException

      Throws:
        `JsonMappingException`
      Since:
        1.8

    - #### createTreeDeserializer

          public abstract JsonDeserializer<?> createTreeDeserializer(DeserializationConfig config,
                                                   DeserializerProvider p,
                                                   JavaType type,
                                                   BeanProperty property)
                                                              throws JsonMappingException

      Method called to create and return a deserializer that can construct JsonNode(s) from JSON content.
      Throws:
        `JsonMappingException`

    - #### createKeyDeserializer

          public KeyDeserializer createKeyDeserializer(DeserializationConfig config,
                                              JavaType type,
                                              BeanProperty property)
                                                throws JsonMappingException

      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.
      Returns:
        Key deserializer to use for specified type, if one found; null if not (and default key deserializer should be used)
      Throws:
        `JsonMappingException`
      Since:
        1.8

    - #### findTypeDeserializer

          public TypeDeserializer findTypeDeserializer(DeserializationConfig config,
                                              JavaType baseType,
                                              BeanProperty property)
                                                throws JsonMappingException

      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.

      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`
      Since:
        1.5