java.lang.Object
tools.jackson.databind.deser.DeserializerFactory
- Direct Known Subclasses:
BasicDeserializerFactory
Abstract class that defines API used by
DeserializationContext
to construct actual
ValueDeserializer 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(tools.jackson.databind.DeserializationContext, tools.jackson.databind.type.ArrayType, tools.jackson.databind.BeanDescription.Supplier)) and the other for other Java containers likeLists andSets (createCollectionDeserializer(tools.jackson.databind.DeserializationContext, tools.jackson.databind.type.CollectionType, tools.jackson.databind.BeanDescription.Supplier)). 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
Maps (createMapDeserializer(tools.jackson.databind.DeserializationContext, tools.jackson.databind.type.MapType, tools.jackson.databind.BeanDescription.Supplier)), and another for POJOs (createBeanDeserializer(tools.jackson.databind.DeserializationContext, tools.jackson.databind.JavaType, tools.jackson.databind.BeanDescription.Supplier). 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 iscreateTreeDeserializer(tools.jackson.databind.DeserializationConfig, tools.jackson.databind.JavaType, tools.jackson.databind.BeanDescription.Supplier) - For enumerated types (
Enum) there iscreateEnumDeserializer(tools.jackson.databind.DeserializationContext, tools.jackson.databind.JavaType, tools.jackson.databind.BeanDescription.Supplier) - For all other types,
createBeanDeserializer(tools.jackson.databind.DeserializationContext, tools.jackson.databind.JavaType, tools.jackson.databind.BeanDescription.Supplier)is used.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract ValueDeserializer<?>createArrayDeserializer(DeserializationContext ctxt, ArrayType type, BeanDescription.Supplier beanDescRef) Method called to create (or, for completely immutable deserializers, reuse) a deserializer that can convert JSON content into values of specified Java type.abstract ValueDeserializer<Object>createBeanDeserializer(DeserializationContext ctxt, JavaType type, BeanDescription.Supplier beanDescRef) 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 ValueDeserializer<Object>createBuilderBasedDeserializer(DeserializationContext ctxt, JavaType type, BeanDescription.Supplier beanDescRef, Class<?> builderClass) Method called to create a deserializer that will use specified Builder class for building value instances.abstract ValueDeserializer<?>createCollectionDeserializer(DeserializationContext ctxt, CollectionType type, BeanDescription.Supplier beanDescRef) abstract ValueDeserializer<?>createCollectionLikeDeserializer(DeserializationContext ctxt, CollectionLikeType type, BeanDescription.Supplier beanDescRef) abstract ValueDeserializer<?>createEnumDeserializer(DeserializationContext ctxt, JavaType type, BeanDescription.Supplier beanDescRef) abstract KeyDeserializercreateKeyDeserializer(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 ValueDeserializer<?>createMapDeserializer(DeserializationContext ctxt, MapType type, BeanDescription.Supplier beanDescRef) abstract ValueDeserializer<?>createMapLikeDeserializer(DeserializationContext ctxt, MapLikeType type, BeanDescription.Supplier beanDescRef) abstract ValueDeserializer<?>createReferenceDeserializer(DeserializationContext ctxt, ReferenceType type, BeanDescription.Supplier beanDescRef) abstract ValueDeserializer<?>createTreeDeserializer(DeserializationConfig config, JavaType type, BeanDescription.Supplier beanDescRef) Method called to create and return a deserializer that can construct JsonNode(s) from JSON content.abstract ValueInstantiatorfindValueInstantiator(DeserializationContext ctxt, BeanDescription.Supplier beanDescRef) Method that is to find all creators (constructors, factory methods) for the bean type to deserialize.abstract booleanhasExplicitDeserializerFor(DatabindContext ctxt, Class<?> valueType) Method that can be used to check if databind module has explicitly declared deserializer for given (likely JDK) type, explicit meaning that there is specific deserializer for given type as opposed to auto-generated "Bean" deserializer.abstract DeserializerFactorywithAdditionalDeserializers(Deserializers additional) Convenience method for creating a new factory instance with additional deserializer provider.abstract DeserializerFactorywithAdditionalKeyDeserializers(KeyDeserializers additional) Convenience method for creating a new factory instance with additionalKeyDeserializers.abstract DeserializerFactoryConvenience method for creating a new factory instance with additionalValueDeserializerModifier.abstract DeserializerFactorywithValueInstantiators(ValueInstantiators instantiators) Convenience method for creating a new factory instance with additionalValueInstantiators.
-
Field Details
-
NO_DESERIALIZERS
-
-
Constructor Details
-
DeserializerFactory
public DeserializerFactory()
-
-
Method Details
-
findValueInstantiator
public abstract ValueInstantiator findValueInstantiator(DeserializationContext ctxt, BeanDescription.Supplier beanDescRef) Method that is to find all creators (constructors, factory methods) for the bean type to deserialize. -
createBeanDeserializer
public abstract ValueDeserializer<Object> createBeanDeserializer(DeserializationContext ctxt, JavaType type, BeanDescription.Supplier beanDescRef) 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
-
createBuilderBasedDeserializer
public abstract ValueDeserializer<Object> createBuilderBasedDeserializer(DeserializationContext ctxt, JavaType type, BeanDescription.Supplier beanDescRef, Class<?> builderClass) Method called to create a deserializer that will use specified Builder class for building value instances. -
createEnumDeserializer
public abstract ValueDeserializer<?> createEnumDeserializer(DeserializationContext ctxt, JavaType type, BeanDescription.Supplier beanDescRef) -
createReferenceDeserializer
public abstract ValueDeserializer<?> createReferenceDeserializer(DeserializationContext ctxt, ReferenceType type, BeanDescription.Supplier beanDescRef) -
createTreeDeserializer
public abstract ValueDeserializer<?> createTreeDeserializer(DeserializationConfig config, JavaType type, BeanDescription.Supplier beanDescRef) Method called to create and return a deserializer that can construct JsonNode(s) from JSON content. -
createArrayDeserializer
public abstract ValueDeserializer<?> createArrayDeserializer(DeserializationContext ctxt, ArrayType type, BeanDescription.Supplier beanDescRef) 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
-
createCollectionDeserializer
public abstract ValueDeserializer<?> createCollectionDeserializer(DeserializationContext ctxt, CollectionType type, BeanDescription.Supplier beanDescRef) -
createCollectionLikeDeserializer
public abstract ValueDeserializer<?> createCollectionLikeDeserializer(DeserializationContext ctxt, CollectionLikeType type, BeanDescription.Supplier beanDescRef) -
createMapDeserializer
public abstract ValueDeserializer<?> createMapDeserializer(DeserializationContext ctxt, MapType type, BeanDescription.Supplier beanDescRef) -
createMapLikeDeserializer
public abstract ValueDeserializer<?> createMapLikeDeserializer(DeserializationContext ctxt, MapLikeType type, BeanDescription.Supplier beanDescRef) -
createKeyDeserializer
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)
-
hasExplicitDeserializerFor
Method that can be used to check if databind module has explicitly declared deserializer for given (likely JDK) type, explicit meaning that there is specific deserializer for given type as opposed to auto-generated "Bean" deserializer. Factory itself will check for known JDK-provided types, but registeredJacksonModules are also called to see if they might provide explicit deserializer.Main use for this method is with Safe Default Typing (and generally Safe Polymorphic Deserialization), during which it is good to be able to check that given raw type is explicitly supported and as such "known type" (as opposed to potentially dangerous "gadget type" which could be exploited).
This matches
Deserializers.Base.hasDeserializerFor(Class)method, which is the mechanism used to determine if aModulemight provide an explicit deserializer instead of core databind. -
withAdditionalDeserializers
Convenience method for creating a new factory instance with additional deserializer provider. -
withAdditionalKeyDeserializers
Convenience method for creating a new factory instance with additionalKeyDeserializers. -
withDeserializerModifier
Convenience method for creating a new factory instance with additionalValueDeserializerModifier. -
withValueInstantiators
Convenience method for creating a new factory instance with additionalValueInstantiators.
-