com.fasterxml.jackson.databind.deser

## Class DeserializerFactory

- java.lang.Object
- - com.fasterxml.jackson.databind.deser.DeserializerFactory

- Direct Known Subclasses:
    BasicDeserializerFactory

      public abstract class DeserializerFactory
      extends Object

  Abstract class that defines API used by `DeserializationContext` to construct actual `JsonDeserializer` instances (which are then cached by context and/or dedicated cache).

  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(com.fasterxml.jackson.databind.DeserializationContext, com.fasterxml.jackson.databind.type.ArrayType, com.fasterxml.jackson.databind.BeanDescription)`) and the other for other Java containers like `List`s and `Set`s (`createCollectionDeserializer(com.fasterxml.jackson.databind.DeserializationContext, com.fasterxml.jackson.databind.type.CollectionType, com.fasterxml.jackson.databind.BeanDescription)`). Actually there is also a third method for "Collection-like" types; things like Scala collections that act like JDK collections but do not implement same interfaces.
  - For JSON "Object" type, we need 2 methods: one to deal with expected Java `Map`s (`createMapDeserializer(com.fasterxml.jackson.databind.DeserializationContext, com.fasterxml.jackson.databind.type.MapType, com.fasterxml.jackson.databind.BeanDescription)`), and another for POJOs (`createBeanDeserializer(com.fasterxml.jackson.databind.DeserializationContext, com.fasterxml.jackson.databind.JavaType, com.fasterxml.jackson.databind.BeanDescription)`. As an additional twist there is also a callback for "Map-like" types, mostly to make it possible to support Scala Maps (which are NOT JDK Map compatible).
  - For Tree Model (`JsonNode`) properties there is `createTreeDeserializer(com.fasterxml.jackson.databind.DeserializationConfig, com.fasterxml.jackson.databind.JavaType, com.fasterxml.jackson.databind.BeanDescription)`
  - For enumerated types (`Enum`) there is `createEnumDeserializer(com.fasterxml.jackson.databind.DeserializationContext, com.fasterxml.jackson.databind.JavaType, com.fasterxml.jackson.databind.BeanDescription)`
  - For all other types, `createBeanDeserializer(com.fasterxml.jackson.databind.DeserializationContext, com.fasterxml.jackson.databind.JavaType, com.fasterxml.jackson.databind.BeanDescription)` is used.

- - ### Field Summary

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

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DeserializerFactory()`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `abstract 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.
    `abstract JsonDeserializer<Object>` | `createBeanDeserializer(DeserializationContext ctxt, JavaType 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 "bean" (POJO) type.
    `abstract JsonDeserializer<Object>` | `createBuilderBasedDeserializer(DeserializationContext ctxt, JavaType type, BeanDescription beanDesc, Class<?> builderClass)` Method called to create a deserializer that will use specified Builder class for building value instances.
    `abstract JsonDeserializer<?>` | `createCollectionDeserializer(DeserializationContext ctxt, CollectionType type, BeanDescription beanDesc)`
    `abstract JsonDeserializer<?>` | `createCollectionLikeDeserializer(DeserializationContext ctxt, CollectionLikeType type, BeanDescription beanDesc)`
    `abstract JsonDeserializer<?>` | `createEnumDeserializer(DeserializationContext ctxt, JavaType type, BeanDescription beanDesc)`
    `abstract 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.
    `abstract JsonDeserializer<?>` | `createMapDeserializer(DeserializationContext ctxt, MapType type, BeanDescription beanDesc)`
    `abstract JsonDeserializer<?>` | `createMapLikeDeserializer(DeserializationContext ctxt, MapLikeType type, BeanDescription beanDesc)`
    `abstract JsonDeserializer<?>` | `createReferenceDeserializer(DeserializationContext ctxt, ReferenceType type, BeanDescription beanDesc)`
    `abstract JsonDeserializer<?>` | `createTreeDeserializer(DeserializationConfig config, JavaType type, BeanDescription beanDesc)` Method called to create and return a deserializer that can construct JsonNode(s) from JSON content.
    `abstract TypeDeserializer` | `findTypeDeserializer(DeserializationConfig config, JavaType baseType)` Method called to find and create a type information deserializer for given base type, if one is needed.
    `abstract ValueInstantiator` | `findValueInstantiator(DeserializationContext ctxt, BeanDescription beanDesc)` Method that is to find all creators (constructors, factory methods) for the bean type to deserialize.
    `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).
    `abstract DeserializerFactory` | `withAbstractTypeResolver(AbstractTypeResolver resolver)` Convenience method for creating a new factory instance with additional `AbstractTypeResolver`.
    `abstract DeserializerFactory` | `withAdditionalDeserializers(Deserializers additional)` Convenience method for creating a new factory instance with additional deserializer provider.
    `abstract DeserializerFactory` | `withAdditionalKeyDeserializers(KeyDeserializers additional)` Convenience method for creating a new factory instance with additional `KeyDeserializers`.
    `abstract DeserializerFactory` | `withDeserializerModifier(BeanDeserializerModifier modifier)` Convenience method for creating a new factory instance with additional `BeanDeserializerModifier`.
    `abstract 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

    - #### withAdditionalDeserializers

          public abstract DeserializerFactory withAdditionalDeserializers(Deserializers additional)

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

    - #### withAdditionalKeyDeserializers

          public abstract DeserializerFactory withAdditionalKeyDeserializers(KeyDeserializers additional)

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

    - #### withDeserializerModifier

          public abstract DeserializerFactory withDeserializerModifier(BeanDeserializerModifier modifier)

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

    - #### withAbstractTypeResolver

          public abstract DeserializerFactory withAbstractTypeResolver(AbstractTypeResolver resolver)

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

    - #### withValueInstantiators

          public abstract DeserializerFactory withValueInstantiators(ValueInstantiators instantiators)

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

    - #### 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`

    - #### findValueInstantiator

          public abstract ValueInstantiator findValueInstantiator(DeserializationContext ctxt,
                                                                  BeanDescription beanDesc)
                                                           throws JsonMappingException

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

    - #### createBeanDeserializer

          public abstract JsonDeserializer<Object> createBeanDeserializer(DeserializationContext ctxt,
                                                                          JavaType type,
                                                                          BeanDescription beanDesc)
                                                                   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
      Throws:
        `JsonMappingException`

    - #### createBuilderBasedDeserializer

          public abstract JsonDeserializer<Object> createBuilderBasedDeserializer(DeserializationContext ctxt,
                                                                                  JavaType type,
                                                                                  BeanDescription beanDesc,
                                                                                  Class<?> builderClass)
                                                                           throws JsonMappingException

      Method called to create a deserializer that will use specified Builder class for building value instances.
      Throws:
        `JsonMappingException`

    - #### createEnumDeserializer

          public abstract JsonDeserializer<?> createEnumDeserializer(DeserializationContext ctxt,
                                                                     JavaType type,
                                                                     BeanDescription beanDesc)
                                                              throws JsonMappingException

      Throws:
        `JsonMappingException`

    - #### createReferenceDeserializer

          public abstract JsonDeserializer<?> createReferenceDeserializer(DeserializationContext ctxt,
                                                                          ReferenceType type,
                                                                          BeanDescription beanDesc)
                                                                   throws JsonMappingException

      Throws:
        `JsonMappingException`
      Since:
        2.7

    - #### createTreeDeserializer

          public abstract JsonDeserializer<?> createTreeDeserializer(DeserializationConfig config,
                                                                     JavaType type,
                                                                     BeanDescription beanDesc)
                                                              throws JsonMappingException

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

    - #### createArrayDeserializer

          public abstract JsonDeserializer<?> createArrayDeserializer(DeserializationContext ctxt,
                                                                      ArrayType type,
                                                                      BeanDescription beanDesc)
                                                               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
      Throws:
        `JsonMappingException`

    - #### createCollectionDeserializer

          public abstract JsonDeserializer<?> createCollectionDeserializer(DeserializationContext ctxt,
                                                                           CollectionType type,
                                                                           BeanDescription beanDesc)
                                                                    throws JsonMappingException

      Throws:
        `JsonMappingException`

    - #### createCollectionLikeDeserializer

          public abstract JsonDeserializer<?> createCollectionLikeDeserializer(DeserializationContext ctxt,
                                                                               CollectionLikeType type,
                                                                               BeanDescription beanDesc)
                                                                        throws JsonMappingException

      Throws:
        `JsonMappingException`

    - #### createMapDeserializer

          public abstract JsonDeserializer<?> createMapDeserializer(DeserializationContext ctxt,
                                                                    MapType type,
                                                                    BeanDescription beanDesc)
                                                             throws JsonMappingException

      Throws:
        `JsonMappingException`

    - #### createMapLikeDeserializer

          public abstract JsonDeserializer<?> createMapLikeDeserializer(DeserializationContext ctxt,
                                                                        MapLikeType type,
                                                                        BeanDescription beanDesc)
                                                                 throws JsonMappingException

      Throws:
        `JsonMappingException`

    - #### createKeyDeserializer

          public abstract KeyDeserializer createKeyDeserializer(DeserializationContext ctxt,
                                                                JavaType type)
                                                         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`

    - #### findTypeDeserializer

          public abstract TypeDeserializer findTypeDeserializer(DeserializationConfig config,
                                                                JavaType baseType)
                                                         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`

Copyright © 2008–2018 FasterXML. All rights reserved.