Class BeanDeserializerBase
- java.lang.Object
-
- com.fasterxml.jackson.databind.JsonDeserializer<T>
-
- com.fasterxml.jackson.databind.deser.std.StdDeserializer<java.lang.Object>
-
- com.fasterxml.jackson.databind.deser.BeanDeserializerBase
-
- All Implemented Interfaces:
ContextualDeserializer
,NullValueProvider
,ResolvableDeserializer
,ValueInstantiator.Gettable
,java.io.Serializable
- Direct Known Subclasses:
BeanAsArrayBuilderDeserializer
,BeanAsArrayDeserializer
,BeanDeserializer
,BuilderBasedDeserializer
public abstract class BeanDeserializerBase extends StdDeserializer<java.lang.Object> implements ContextualDeserializer, ResolvableDeserializer, ValueInstantiator.Gettable, java.io.Serializable
Base class forBeanDeserializer
.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.fasterxml.jackson.databind.JsonDeserializer
JsonDeserializer.None
-
-
Constructor Summary
Constructors Constructor Description BeanDeserializerBase(BeanDeserializerBase src, ObjectIdReader oir)
BeanDeserializerBase(BeanDeserializerBase src, java.util.Set<java.lang.String> ignorableProps, java.util.Set<java.lang.String> includableProps)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description JsonDeserializer<?>
createContextual(DeserializationContext ctxt, BeanProperty property)
Although most of post-processing is done in resolve(), we only get access to referring property's annotations here; and this is needed to support per-property ObjectIds.java.util.Iterator<SettableBeanProperty>
creatorProperties()
Accessor for finding properties that represents values to pass through property-based creator method (constructor or factory method)java.lang.Object
deserializeFromArray(JsonParser p, DeserializationContext ctxt)
Deprecated.Since 2.11 Should not be used: was never meant to be called by code other than sub-classes (implementations), and implementations details differjava.lang.Object
deserializeFromBoolean(JsonParser p, DeserializationContext ctxt)
Method called to deserialize POJO value from a JSON boolean value (true, false)java.lang.Object
deserializeFromDouble(JsonParser p, DeserializationContext ctxt)
Method called to deserialize POJO value from a JSON floating-point number.java.lang.Object
deserializeFromEmbedded(JsonParser p, DeserializationContext ctxt)
java.lang.Object
deserializeFromNumber(JsonParser p, DeserializationContext ctxt)
abstract java.lang.Object
deserializeFromObject(JsonParser p, DeserializationContext ctxt)
General version used when handling needs more advanced features.java.lang.Object
deserializeFromString(JsonParser p, DeserializationContext ctxt)
java.lang.Object
deserializeWithType(JsonParser p, DeserializationContext ctxt, TypeDeserializer typeDeserializer)
Base implementation that does not assume specific type inclusion mechanism.SettableBeanProperty
findBackReference(java.lang.String logicalName)
Method needed byBeanDeserializerFactory
to properly link managed- and back-reference pairs.SettableBeanProperty
findProperty(int propertyIndex)
Alternate find method that tries to locate a property with givenproperty index
.SettableBeanProperty
findProperty(PropertyName propertyName)
SettableBeanProperty
findProperty(java.lang.String propertyName)
Accessor for finding the property with given name, if POJO has one.java.lang.Class<?>
getBeanClass()
Deprecated.Since 2.3, usehandledType()
insteadAccessPattern
getEmptyAccessPattern()
This method may be called in conjunction with calls toJsonDeserializer.getEmptyValue(DeserializationContext)
, to check whether it needs to be called just once (static values), or each time empty value is needed.java.lang.Object
getEmptyValue(DeserializationContext ctxt)
Method called to determine value to be used for "empty" values (most commonly when deserializing from empty JSON Strings).java.util.Collection<java.lang.Object>
getKnownPropertyNames()
Method that will either return null to indicate that type being deserializers has no concept of properties; or a collection of identifiers for whichtoString
will give external property name.AccessPattern
getNullAccessPattern()
This method may be called in conjunction with calls toJsonDeserializer.getNullValue(DeserializationContext)
, to check whether it needs to be called just once (static values), or each time empty value is needed.ObjectIdReader
getObjectIdReader()
Overridden to return true for those instances that are handling value for which Object Identity handling is enabled (either via value type or referring property).int
getPropertyCount()
Accessor for checking number of deserialized properties.ValueInstantiator
getValueInstantiator()
JavaType
getValueType()
Exact structured type this deserializer handles, if known.java.lang.Class<?>
handledType()
Method for accessing concrete physical type of values this deserializer produces.boolean
hasProperty(java.lang.String propertyName)
boolean
hasViews()
boolean
isCachable()
Method called to see if deserializer instance is cachable and usable for other properties of same type (type for which instance was created).boolean
isCaseInsensitive()
Accessor for checking whether this deserializer is operating in case-insensitive manner.LogicalType
logicalType()
Method for accessing logical type of values this deserializer produces.java.util.Iterator<SettableBeanProperty>
properties()
Accessor for iterating over properties this deserializer uses; with the exception that properties passed via Creator methods (specifically, "property-based constructor") are not included, but can be accessed separate by callingcreatorProperties()
void
replaceProperty(SettableBeanProperty original, SettableBeanProperty replacement)
Method that can be used to replace an existing property with a modified one.void
resolve(DeserializationContext ctxt)
Method called to finalize setup of this deserializer, after deserializer itself has been registered.java.lang.Boolean
supportsUpdate(DeserializationConfig config)
Introspection method that may be called to see whether deserializer supports update of an existing value (aka "merging") or not.abstract JsonDeserializer<java.lang.Object>
unwrappingDeserializer(NameTransformer unwrapper)
Method that will return deserializer instance that is able to handle "unwrapped" value instances If no unwrapped instance can be constructed, will simply return this object as-is.BeanDeserializerBase
withBeanProperties(BeanPropertyMap props)
Mutant factory method that custom sub-classes must override; not left as abstract to prevent more drastic backwards compatibility problems.abstract BeanDeserializerBase
withByNameInclusion(java.util.Set<java.lang.String> ignorableProps, java.util.Set<java.lang.String> includableProps)
BeanDeserializerBase
withIgnorableProperties(java.util.Set<java.lang.String> ignorableProps)
Deprecated.Since 2.12 usewithByNameInclusion(java.util.Set<java.lang.String>, java.util.Set<java.lang.String>)
insteadabstract BeanDeserializerBase
withIgnoreAllUnknown(boolean ignoreUnknown)
abstract BeanDeserializerBase
withObjectIdReader(ObjectIdReader oir)
void
wrapAndThrow(java.lang.Throwable t, java.lang.Object bean, java.lang.String fieldName, DeserializationContext ctxt)
Method that will modify caught exception (passed in as argument) as necessary to include reference information, and to ensure it is a subtype ofIOException
, or an unchecked exception.-
Methods inherited from class com.fasterxml.jackson.databind.deser.std.StdDeserializer
getValueClass, getValueType
-
Methods inherited from class com.fasterxml.jackson.databind.JsonDeserializer
deserialize, deserialize, deserializeWithType, getAbsentValue, getDelegatee, getEmptyValue, getNullValue, getNullValue, replaceDelegatee
-
-
-
-
Constructor Detail
-
BeanDeserializerBase
public BeanDeserializerBase(BeanDeserializerBase src, ObjectIdReader oir)
-
BeanDeserializerBase
public BeanDeserializerBase(BeanDeserializerBase src, java.util.Set<java.lang.String> ignorableProps, java.util.Set<java.lang.String> includableProps)
- Since:
- 2.12
-
-
Method Detail
-
unwrappingDeserializer
public abstract JsonDeserializer<java.lang.Object> unwrappingDeserializer(NameTransformer unwrapper)
Description copied from class:JsonDeserializer
Method that will return deserializer instance that is able to handle "unwrapped" value instances If no unwrapped instance can be constructed, will simply return this object as-is.Default implementation just returns 'this' indicating that no unwrapped variant exists
- Overrides:
unwrappingDeserializer
in classJsonDeserializer<java.lang.Object>
-
withObjectIdReader
public abstract BeanDeserializerBase withObjectIdReader(ObjectIdReader oir)
-
withByNameInclusion
public abstract BeanDeserializerBase withByNameInclusion(java.util.Set<java.lang.String> ignorableProps, java.util.Set<java.lang.String> includableProps)
- Since:
- 2.12
-
withIgnoreAllUnknown
public abstract BeanDeserializerBase withIgnoreAllUnknown(boolean ignoreUnknown)
- Since:
- 2.11
-
withBeanProperties
public BeanDeserializerBase withBeanProperties(BeanPropertyMap props)
Mutant factory method that custom sub-classes must override; not left as abstract to prevent more drastic backwards compatibility problems.- Since:
- 2.8
-
withIgnorableProperties
@Deprecated public BeanDeserializerBase withIgnorableProperties(java.util.Set<java.lang.String> ignorableProps)
Deprecated.Since 2.12 usewithByNameInclusion(java.util.Set<java.lang.String>, java.util.Set<java.lang.String>)
instead
-
resolve
public void resolve(DeserializationContext ctxt) throws JsonMappingException
Method called to finalize setup of this deserializer, after deserializer itself has been registered. This is needed to handle recursive and transitive dependencies.- Specified by:
resolve
in interfaceResolvableDeserializer
- Parameters:
ctxt
- Context to use for accessing configuration, resolving secondary deserializers- Throws:
JsonMappingException
-
createContextual
public JsonDeserializer<?> createContextual(DeserializationContext ctxt, BeanProperty property) throws JsonMappingException
Although most of post-processing is done in resolve(), we only get access to referring property's annotations here; and this is needed to support per-property ObjectIds. We will also consider Shape transformations (read from Array) at this point, since it may come from either Class definition or property.- Specified by:
createContextual
in interfaceContextualDeserializer
- Parameters:
ctxt
- Deserialization context to access configuration, additional deserializers that may be needed by this deserializerproperty
- Method, field or constructor parameter that represents the property (and is used to assign deserialized value). Should be available; but there may be cases where caller cannot provide it and null is passed instead (in which case impls usually pass 'this' deserializer as is)- Returns:
- Deserializer to use for deserializing values of specified property; may be this instance or a new instance.
- Throws:
JsonMappingException
-
getNullAccessPattern
public AccessPattern getNullAccessPattern()
Description copied from class:JsonDeserializer
This method may be called in conjunction with calls toJsonDeserializer.getNullValue(DeserializationContext)
, to check whether it needs to be called just once (static values), or each time empty value is needed.Default implementation indicates that the "null value" to use for input null does not vary across uses so that
JsonDeserializer.getNullValue(DeserializationContext)
need not be called more than once per deserializer instance. This information may be used as optimization.- Specified by:
getNullAccessPattern
in interfaceNullValueProvider
- Overrides:
getNullAccessPattern
in classJsonDeserializer<java.lang.Object>
-
getEmptyAccessPattern
public AccessPattern getEmptyAccessPattern()
Description copied from class:JsonDeserializer
This method may be called in conjunction with calls toJsonDeserializer.getEmptyValue(DeserializationContext)
, to check whether it needs to be called just once (static values), or each time empty value is needed.- Overrides:
getEmptyAccessPattern
in classJsonDeserializer<java.lang.Object>
-
getEmptyValue
public java.lang.Object getEmptyValue(DeserializationContext ctxt) throws JsonMappingException
Description copied from class:JsonDeserializer
Method called to determine value to be used for "empty" values (most commonly when deserializing from empty JSON Strings). Usually this is same asJsonDeserializer.getNullValue(com.fasterxml.jackson.databind.DeserializationContext)
(which in turn is usually simply Java null), but it can be overridden for specific types. Or, if type should never be converted from empty String, method can also throw an exception.This method may be called once, or multiple times, depending on what
JsonDeserializer.getEmptyAccessPattern()
returns.Default implementation simply calls
JsonDeserializer.getNullValue(com.fasterxml.jackson.databind.DeserializationContext)
and returns value.- Overrides:
getEmptyValue
in classJsonDeserializer<java.lang.Object>
- Throws:
JsonMappingException
-
isCachable
public boolean isCachable()
Description copied from class:JsonDeserializer
Method called to see if deserializer instance is cachable and usable for other properties of same type (type for which instance was created).Note that cached instances are still resolved on per-property basis, if instance implements
ResolvableDeserializer
: cached instance is just as the base. This means that in most cases it is safe to cache instances; however, it only makes sense to cache instances if instantiation is expensive, or if instances are heavy-weight.Default implementation returns false, to indicate that no caching is done.
- Overrides:
isCachable
in classJsonDeserializer<java.lang.Object>
-
isCaseInsensitive
public boolean isCaseInsensitive()
Accessor for checking whether this deserializer is operating in case-insensitive manner.- Returns:
- True if this deserializer should match property names without considering casing; false if case has to match exactly.
- Since:
- 2.12
-
supportsUpdate
public java.lang.Boolean supportsUpdate(DeserializationConfig config)
Description copied from class:JsonDeserializer
Introspection method that may be called to see whether deserializer supports update of an existing value (aka "merging") or not. Return value should either beBoolean.FALSE
if update is not supported at all (immutable values);Boolean.TRUE
if update should usually work (regular POJOs, for example), ornull
if this is either not known, or may sometimes work.Information gathered is typically used to either prevent merging update for property (either by skipping, if based on global defaults; or by exception during deserialization construction if explicit attempt made) if
Boolean.FALSE
returned, or inclusion ifBoolean.TRUE
is specified. If "unknown" case (null
returned) behavior is to exclude property if global defaults used; or to allow if explicit per-type or property merging is defined.Default implementation returns
null
to allow explicit per-type or per-property attempts.- Overrides:
supportsUpdate
in classJsonDeserializer<java.lang.Object>
-
handledType
public java.lang.Class<?> handledType()
Description copied from class:JsonDeserializer
Method for accessing concrete physical type of values this deserializer produces. Note that this information is not guaranteed to be exact -- it may be a more generic (super-type) -- but it should not be incorrect (return a non-related type).Default implementation will return null, which means almost same same as returning
Object.class
would; that is, that nothing is known about handled type.- Overrides:
handledType
in classStdDeserializer<java.lang.Object>
- Returns:
- Physical type of values this deserializer produces, if known;
null
if not
-
getObjectIdReader
public ObjectIdReader getObjectIdReader()
Overridden to return true for those instances that are handling value for which Object Identity handling is enabled (either via value type or referring property).- Overrides:
getObjectIdReader
in classJsonDeserializer<java.lang.Object>
- Returns:
- ObjectIdReader used for resolving possible Object Identifier value, instead of full value serialization, if deserializer can do that; null if no Object Id is expected.
-
hasProperty
public boolean hasProperty(java.lang.String propertyName)
-
hasViews
public boolean hasViews()
-
getPropertyCount
public int getPropertyCount()
Accessor for checking number of deserialized properties.
-
getKnownPropertyNames
public java.util.Collection<java.lang.Object> getKnownPropertyNames()
Description copied from class:JsonDeserializer
Method that will either return null to indicate that type being deserializers has no concept of properties; or a collection of identifiers for whichtoString
will give external property name. This is only to be used for error reporting and diagnostics purposes (most commonly, to accompany "unknown property" exception).- Overrides:
getKnownPropertyNames
in classJsonDeserializer<java.lang.Object>
-
getBeanClass
@Deprecated public final java.lang.Class<?> getBeanClass()
Deprecated.Since 2.3, usehandledType()
instead
-
getValueType
public JavaType getValueType()
Description copied from class:StdDeserializer
Exact structured type this deserializer handles, if known.- Overrides:
getValueType
in classStdDeserializer<java.lang.Object>
-
logicalType
public LogicalType logicalType()
Description copied from class:JsonDeserializer
Method for accessing logical type of values this deserializer produces. Typically used for further configuring handling of values, for example, to find which coercions are legal.- Overrides:
logicalType
in classJsonDeserializer<java.lang.Object>
- Returns:
- Logical type of values this deserializer produces, if known;
null
if not
-
properties
public java.util.Iterator<SettableBeanProperty> properties()
Accessor for iterating over properties this deserializer uses; with the exception that properties passed via Creator methods (specifically, "property-based constructor") are not included, but can be accessed separate by callingcreatorProperties()
-
creatorProperties
public java.util.Iterator<SettableBeanProperty> creatorProperties()
Accessor for finding properties that represents values to pass through property-based creator method (constructor or factory method)- Since:
- 2.0
-
findProperty
public SettableBeanProperty findProperty(PropertyName propertyName)
-
findProperty
public SettableBeanProperty findProperty(java.lang.String propertyName)
Accessor for finding the property with given name, if POJO has one. Name used is the external name, i.e. name used in external data representation (JSON).- Since:
- 2.0
-
findProperty
public SettableBeanProperty findProperty(int propertyIndex)
Alternate find method that tries to locate a property with givenproperty index
. Note that access by index is not necessarily faster than by name, since properties are not directly indexable; however, for most instances difference is not significant as number of properties is low.- Since:
- 2.3
-
findBackReference
public SettableBeanProperty findBackReference(java.lang.String logicalName)
Method needed byBeanDeserializerFactory
to properly link managed- and back-reference pairs.- Overrides:
findBackReference
in classJsonDeserializer<java.lang.Object>
-
getValueInstantiator
public ValueInstantiator getValueInstantiator()
- Specified by:
getValueInstantiator
in interfaceValueInstantiator.Gettable
- Overrides:
getValueInstantiator
in classStdDeserializer<java.lang.Object>
-
replaceProperty
public void replaceProperty(SettableBeanProperty original, SettableBeanProperty replacement)
Method that can be used to replace an existing property with a modified one.NOTE: only ever use this method if you know what you are doing; incorrect usage can break deserializer.
- Parameters:
original
- Property to replacereplacement
- Property to replace it with- Since:
- 2.1
-
deserializeFromObject
public abstract java.lang.Object deserializeFromObject(JsonParser p, DeserializationContext ctxt) throws java.io.IOException
General version used when handling needs more advanced features.- Throws:
java.io.IOException
-
deserializeWithType
public java.lang.Object deserializeWithType(JsonParser p, DeserializationContext ctxt, TypeDeserializer typeDeserializer) throws java.io.IOException
Description copied from class:StdDeserializer
Base implementation that does not assume specific type inclusion mechanism. Sub-classes are expected to override this method if they are to handle type information.- Overrides:
deserializeWithType
in classStdDeserializer<java.lang.Object>
typeDeserializer
- Deserializer to use for handling type information- Throws:
java.io.IOException
-
deserializeFromNumber
public java.lang.Object deserializeFromNumber(JsonParser p, DeserializationContext ctxt) throws java.io.IOException
- Throws:
java.io.IOException
-
deserializeFromString
public java.lang.Object deserializeFromString(JsonParser p, DeserializationContext ctxt) throws java.io.IOException
- Throws:
java.io.IOException
-
deserializeFromDouble
public java.lang.Object deserializeFromDouble(JsonParser p, DeserializationContext ctxt) throws java.io.IOException
Method called to deserialize POJO value from a JSON floating-point number.- Throws:
java.io.IOException
-
deserializeFromBoolean
public java.lang.Object deserializeFromBoolean(JsonParser p, DeserializationContext ctxt) throws java.io.IOException
Method called to deserialize POJO value from a JSON boolean value (true, false)- Throws:
java.io.IOException
-
deserializeFromArray
@Deprecated public java.lang.Object deserializeFromArray(JsonParser p, DeserializationContext ctxt) throws java.io.IOException
Deprecated.Since 2.11 Should not be used: was never meant to be called by code other than sub-classes (implementations), and implementations details differ- Throws:
java.io.IOException
-
deserializeFromEmbedded
public java.lang.Object deserializeFromEmbedded(JsonParser p, DeserializationContext ctxt) throws java.io.IOException
- Throws:
java.io.IOException
-
wrapAndThrow
public void wrapAndThrow(java.lang.Throwable t, java.lang.Object bean, java.lang.String fieldName, DeserializationContext ctxt) throws java.io.IOException
Method that will modify caught exception (passed in as argument) as necessary to include reference information, and to ensure it is a subtype ofIOException
, or an unchecked exception.Rules for wrapping and unwrapping are bit complicated; essentially:
- Errors are to be passed as is (if uncovered via unwrapping)
- "Plain" IOExceptions (ones that are not of type
JsonMappingException
are to be passed as is
- Throws:
java.io.IOException
-
-