Class BeanDeserializerBase
- All Implemented Interfaces:
ContextualDeserializer,NullValueProvider,ResolvableDeserializer,ValueInstantiator.Gettable,Serializable
- Direct Known Subclasses:
BeanAsArrayBuilderDeserializer,BeanAsArrayDeserializer,BeanDeserializer,BuilderBasedDeserializer
BeanDeserializer.- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.fasterxml.jackson.databind.JsonDeserializer
JsonDeserializer.None -
Constructor Summary
ConstructorsConstructorDescriptionBeanDeserializerBase(BeanDeserializerBase src, Set<String> ignorableProps, Set<String> includableProps) -
Method Summary
Modifier and TypeMethodDescriptioncreateContextual(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.Accessor for finding properties that represents values to pass through property-based creator method (constructor or factory method)Deprecated.Since 2.11 Should not be used: was never meant to be called by code other than sub-classes (implementations), and implementations details differMethod called to deserialize POJO value from a JSON boolean value (true, false)Method called to deserialize POJO value from a JSON floating-point number.abstract ObjectGeneral version used when handling needs more advanced features.deserializeWithType(JsonParser p, DeserializationContext ctxt, TypeDeserializer typeDeserializer) Base implementation that does not assume specific type inclusion mechanism.findBackReference(String logicalName) Method needed byBeanDeserializerFactoryto properly link managed- and back-reference pairs.findProperty(int propertyIndex) Alternate find method that tries to locate a property with givenproperty index.findProperty(PropertyName propertyName) findProperty(String propertyName) Accessor for finding the property with given name, if POJO has one.final Class<?> Deprecated.Since 2.3, usehandledType()insteadThis 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.Method called to determine value to be used for "empty" values (most commonly when deserializing from empty JSON Strings).Method that will either return null to indicate that type being deserializers has no concept of properties; or a collection of identifiers for whichtoStringwill give external property name.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.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).intAccessor for checking number of deserialized properties.Exact structured type this deserializer handles, if known.Class<?> Method for accessing concrete physical type of values this deserializer produces.booleanhasProperty(String propertyName) booleanhasViews()booleanMethod called to see if deserializer instance is cachable and usable for other properties of same type (type for which instance was created).booleanAccessor for checking whether this deserializer is operating in case-insensitive manner.Method for accessing logical type of values this deserializer produces.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()voidreplaceProperty(SettableBeanProperty original, SettableBeanProperty replacement) Method that can be used to replace an existing property with a modified one.voidMethod called to finalize setup of this deserializer, after deserializer itself has been registered.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<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.Mutant factory method that custom sub-classes must override; not left as abstract to prevent more drastic backwards compatibility problems.abstract BeanDeserializerBasewithByNameInclusion(Set<String> ignorableProps, Set<String> includableProps) withIgnorableProperties(Set<String> ignorableProps) Deprecated.Since 2.12 usewithByNameInclusion(java.util.Set<java.lang.String>, java.util.Set<java.lang.String>)insteadabstract BeanDeserializerBasewithIgnoreAllUnknown(boolean ignoreUnknown) abstract BeanDeserializerBase<T> TwrapAndThrow(Throwable t, Object bean, 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, getValueTypeMethods inherited from class com.fasterxml.jackson.databind.JsonDeserializer
deserialize, deserialize, deserializeWithType, getAbsentValue, getDelegatee, getEmptyValue, getNullValue, getNullValue, replaceDelegatee
-
Constructor Details
-
BeanDeserializerBase
-
BeanDeserializerBase
public BeanDeserializerBase(BeanDeserializerBase src, Set<String> ignorableProps, Set<String> includableProps) - Since:
- 2.12
-
-
Method Details
-
unwrappingDeserializer
Description copied from class:JsonDeserializerMethod 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:
unwrappingDeserializerin classJsonDeserializer<Object>
-
withObjectIdReader
-
withByNameInclusion
public abstract BeanDeserializerBase withByNameInclusion(Set<String> ignorableProps, Set<String> includableProps) - Since:
- 2.12
-
withIgnoreAllUnknown
- Since:
- 2.11
-
withBeanProperties
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.Since 2.12 usewithByNameInclusion(java.util.Set<java.lang.String>, java.util.Set<java.lang.String>)instead -
resolve
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:
resolvein 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:
createContextualin 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
Description copied from class:JsonDeserializerThis 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:
getNullAccessPatternin interfaceNullValueProvider- Overrides:
getNullAccessPatternin classJsonDeserializer<Object>
-
getEmptyAccessPattern
Description copied from class:JsonDeserializerThis 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:
getEmptyAccessPatternin classJsonDeserializer<Object>
-
getEmptyValue
Description copied from class:JsonDeserializerMethod 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:
getEmptyValuein classJsonDeserializer<Object>- Throws:
JsonMappingException
-
isCachable
public boolean isCachable()Description copied from class:JsonDeserializerMethod 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:
isCachablein classJsonDeserializer<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
Description copied from class:JsonDeserializerIntrospection method that may be called to see whether deserializer supports update of an existing value (aka "merging") or not. Return value should either beBoolean.FALSEif update is not supported at all (immutable values);Boolean.TRUEif update should usually work (regular POJOs, for example), ornullif 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 deserializer construction if explicit attempt made) if
Boolean.FALSEreturned, or inclusion ifBoolean.TRUEis specified. If "unknown" case (nullreturned) behavior is to exclude property if global defaults used; or to allow if explicit per-type or property merging is defined.Default implementation returns
nullto allow explicit per-type or per-property attempts.- Overrides:
supportsUpdatein classJsonDeserializer<Object>
-
handledType
Description copied from class:JsonDeserializerMethod 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.classwould; that is, that nothing is known about handled type.- Overrides:
handledTypein classStdDeserializer<Object>- Returns:
- Physical type of values this deserializer produces, if known;
nullif not
-
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:
getObjectIdReaderin classJsonDeserializer<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
-
hasViews
public boolean hasViews() -
getPropertyCount
public int getPropertyCount()Accessor for checking number of deserialized properties. -
getKnownPropertyNames
Description copied from class:JsonDeserializerMethod that will either return null to indicate that type being deserializers has no concept of properties; or a collection of identifiers for whichtoStringwill give external property name. This is only to be used for error reporting and diagnostics purposes (most commonly, to accompany "unknown property" exception).- Overrides:
getKnownPropertyNamesin classJsonDeserializer<Object>
-
getBeanClass
Deprecated.Since 2.3, usehandledType()instead -
getValueType
Description copied from class:StdDeserializerExact structured type this deserializer handles, if known.- Overrides:
getValueTypein classStdDeserializer<Object>
-
logicalType
Description copied from class:JsonDeserializerMethod 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:
logicalTypein classJsonDeserializer<Object>- Returns:
- Logical type of values this deserializer produces, if known;
nullif not
-
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
Accessor for finding properties that represents values to pass through property-based creator method (constructor or factory method)- Since:
- 2.0
-
findProperty
-
findProperty
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
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
Method needed byBeanDeserializerFactoryto properly link managed- and back-reference pairs.- Overrides:
findBackReferencein classJsonDeserializer<Object>
-
getValueInstantiator
- Specified by:
getValueInstantiatorin interfaceValueInstantiator.Gettable- Overrides:
getValueInstantiatorin classStdDeserializer<Object>
-
replaceProperty
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 Object deserializeFromObject(JsonParser p, DeserializationContext ctxt) throws IOException General version used when handling needs more advanced features.- Throws:
IOException
-
deserializeWithType
public Object deserializeWithType(JsonParser p, DeserializationContext ctxt, TypeDeserializer typeDeserializer) throws IOException Description copied from class:StdDeserializerBase 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:
deserializeWithTypein classStdDeserializer<Object>- Parameters:
typeDeserializer- Deserializer to use for handling type information- Throws:
IOException
-
deserializeFromNumber
- Throws:
IOException
-
deserializeFromString
- Throws:
IOException
-
deserializeFromDouble
Method called to deserialize POJO value from a JSON floating-point number.- Throws:
IOException
-
deserializeFromBoolean
Method called to deserialize POJO value from a JSON boolean value (true, false)- Throws:
IOException
-
deserializeFromArray
@Deprecated public Object deserializeFromArray(JsonParser p, DeserializationContext ctxt) throws 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:
IOException
-
deserializeFromEmbedded
- Throws:
IOException
-
wrapAndThrow
public <T> T wrapAndThrow(Throwable t, Object bean, String fieldName, DeserializationContext ctxt) throws 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
JsonMappingExceptionare to be passed as is
- Throws:
IOException
-