Class BasicDeserializerFactory
- java.lang.Object
-
- com.fasterxml.jackson.databind.deser.DeserializerFactory
-
- com.fasterxml.jackson.databind.deser.BasicDeserializerFactory
-
- All Implemented Interfaces:
java.io.Serializable
- Direct Known Subclasses:
BeanDeserializerFactory
public abstract class BasicDeserializerFactory extends DeserializerFactory implements java.io.Serializable
Abstract factory base class that can provide deserializers for standard JDK classes, including collection classes and simple heuristics for "upcasting" common collection interface types (such asCollection
).Since all simple deserializers are eagerly instantiated, and there is no additional introspection or customizability of these types, this factory is stateless.
- See Also:
- Serialized Form
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ValueInstantiator
_valueInstantiatorInstance(DeserializationConfig config, Annotated annotated, java.lang.Object instDef)
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 ofEnum
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<?>
createReferenceDeserializer(DeserializationContext ctxt, ReferenceType 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.JsonDeserializer<?>
findDefaultDeserializer(DeserializationContext ctxt, JavaType type, BeanDescription beanDesc)
Helper method called to find one of default serializers for "well-known" platform types: JDK-provided types, and small number of public Jackson API types.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).DeserializerFactoryConfig
getFactoryConfig()
Method for getting currentDeserializerFactoryConfig
.boolean
hasExplicitDeserializerFor(DeserializationConfig config, java.lang.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.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 additionalAbstractTypeResolver
.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 additionalKeyDeserializers
.DeserializerFactory
withDeserializerModifier(BeanDeserializerModifier modifier)
Convenience method for creating a new factory instance with additionalBeanDeserializerModifier
.DeserializerFactory
withValueInstantiators(ValueInstantiators instantiators)
Convenience method for creating a new factory instance with additionalValueInstantiators
.-
Methods inherited from class com.fasterxml.jackson.databind.deser.DeserializerFactory
createBeanDeserializer, createBuilderBasedDeserializer
-
-
-
-
Method Detail
-
getFactoryConfig
public DeserializerFactoryConfig getFactoryConfig()
Method for getting currentDeserializerFactoryConfig
.Note that since instances are immutable, you can NOT change settings by accessing an instance and calling methods: this will simply create new instance of config object.
-
withAdditionalDeserializers
public final DeserializerFactory withAdditionalDeserializers(Deserializers additional)
Convenience method for creating a new factory instance with additional deserializer provider.- Specified by:
withAdditionalDeserializers
in classDeserializerFactory
-
withAdditionalKeyDeserializers
public final DeserializerFactory withAdditionalKeyDeserializers(KeyDeserializers additional)
Convenience method for creating a new factory instance with additionalKeyDeserializers
.- Specified by:
withAdditionalKeyDeserializers
in classDeserializerFactory
-
withDeserializerModifier
public final DeserializerFactory withDeserializerModifier(BeanDeserializerModifier modifier)
Convenience method for creating a new factory instance with additionalBeanDeserializerModifier
.- Specified by:
withDeserializerModifier
in classDeserializerFactory
-
withAbstractTypeResolver
public final DeserializerFactory withAbstractTypeResolver(AbstractTypeResolver resolver)
Convenience method for creating a new factory instance with additionalAbstractTypeResolver
.- Specified by:
withAbstractTypeResolver
in classDeserializerFactory
-
withValueInstantiators
public final DeserializerFactory withValueInstantiators(ValueInstantiators instantiators)
Convenience method for creating a new factory instance with additionalValueInstantiators
.- Specified by:
withValueInstantiators
in classDeserializerFactory
-
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 classDeserializerFactory
- 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 classDeserializerFactory
- Throws:
JsonMappingException
-
_valueInstantiatorInstance
public ValueInstantiator _valueInstantiatorInstance(DeserializationConfig config, Annotated annotated, java.lang.Object instDef) throws JsonMappingException
- 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 classDeserializerFactory
type
- Type to be deserialized- Throws:
JsonMappingException
-
createCollectionDeserializer
public JsonDeserializer<?> createCollectionDeserializer(DeserializationContext ctxt, CollectionType type, BeanDescription beanDesc) throws JsonMappingException
- Specified by:
createCollectionDeserializer
in classDeserializerFactory
- Throws:
JsonMappingException
-
createCollectionLikeDeserializer
public JsonDeserializer<?> createCollectionLikeDeserializer(DeserializationContext ctxt, CollectionLikeType type, BeanDescription beanDesc) throws JsonMappingException
- Specified by:
createCollectionLikeDeserializer
in classDeserializerFactory
- Throws:
JsonMappingException
-
createMapDeserializer
public JsonDeserializer<?> createMapDeserializer(DeserializationContext ctxt, MapType type, BeanDescription beanDesc) throws JsonMappingException
- Specified by:
createMapDeserializer
in classDeserializerFactory
- Throws:
JsonMappingException
-
createMapLikeDeserializer
public JsonDeserializer<?> createMapLikeDeserializer(DeserializationContext ctxt, MapLikeType type, BeanDescription beanDesc) throws JsonMappingException
- Specified by:
createMapLikeDeserializer
in classDeserializerFactory
- Throws:
JsonMappingException
-
createEnumDeserializer
public JsonDeserializer<?> createEnumDeserializer(DeserializationContext ctxt, JavaType type, BeanDescription beanDesc) throws JsonMappingException
Factory method for constructing serializers ofEnum
types.- Specified by:
createEnumDeserializer
in classDeserializerFactory
- 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 classDeserializerFactory
- Throws:
JsonMappingException
-
createReferenceDeserializer
public JsonDeserializer<?> createReferenceDeserializer(DeserializationContext ctxt, ReferenceType type, BeanDescription beanDesc) throws JsonMappingException
- Specified by:
createReferenceDeserializer
in classDeserializerFactory
- 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 classDeserializerFactory
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 classDeserializerFactory
- Returns:
- Key deserializer to use for specified type, if one found; null if not (and default key deserializer should be used)
- Throws:
JsonMappingException
-
hasExplicitDeserializerFor
public boolean hasExplicitDeserializerFor(DeserializationConfig config, java.lang.Class<?> valueType)
Description copied from class:DeserializerFactory
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 registeredModule
s 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 aModule
might provide an explicit deserializer instead of core databind.- Specified by:
hasExplicitDeserializerFor
in classDeserializerFactory
-
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 typepropertyEntity
- Field or method that contains container property- Throws:
JsonMappingException
-
findDefaultDeserializer
public JsonDeserializer<?> findDefaultDeserializer(DeserializationContext ctxt, JavaType type, BeanDescription beanDesc) throws JsonMappingException
Helper method called to find one of default serializers for "well-known" platform types: JDK-provided types, and small number of public Jackson API types.- Throws:
JsonMappingException
- Since:
- 2.2
-
-