public abstract class BeanDeserializerBase extends StdDeserializer<java.lang.Object> implements ContextualDeserializer, ResolvableDeserializer, ValueInstantiator.Gettable, java.io.Serializable
BeanDeserializer
.JsonDeserializer.None
Constructor and Description |
---|
BeanDeserializerBase(BeanDeserializerBase src,
ObjectIdReader oir) |
BeanDeserializerBase(BeanDeserializerBase src,
java.util.Set<java.lang.String> ignorableProps) |
Modifier and Type | Method and 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) |
java.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 by
BeanDeserializerFactory to properly link
managed- and back-reference pairs. |
SettableBeanProperty |
findProperty(int propertyIndex)
Alternate find method that tries to locate a property with given
property 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, use
handledType() instead |
AccessPattern |
getEmptyAccessPattern()
This method may be called in conjunction with calls to
JsonDeserializer.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 which
toString will give external property
name. |
AccessPattern |
getNullAccessPattern()
This method may be called in conjunction with calls to
JsonDeserializer.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 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).
|
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 calling
creatorProperties() |
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 |
withIgnorableProperties(java.util.Set<java.lang.String> ignorableProps) |
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 of
IOException , or an unchecked exception. |
getValueClass, getValueType
deserialize, deserialize, deserializeWithType, getDelegatee, getEmptyValue, getNullValue, getNullValue, replaceDelegatee
public BeanDeserializerBase(BeanDeserializerBase src, ObjectIdReader oir)
public BeanDeserializerBase(BeanDeserializerBase src, java.util.Set<java.lang.String> ignorableProps)
public abstract JsonDeserializer<java.lang.Object> unwrappingDeserializer(NameTransformer unwrapper)
JsonDeserializer
Default implementation just returns 'this' indicating that no unwrapped variant exists
unwrappingDeserializer
in class JsonDeserializer<java.lang.Object>
public abstract BeanDeserializerBase withObjectIdReader(ObjectIdReader oir)
public abstract BeanDeserializerBase withIgnorableProperties(java.util.Set<java.lang.String> ignorableProps)
public BeanDeserializerBase withBeanProperties(BeanPropertyMap props)
public void resolve(DeserializationContext ctxt) throws JsonMappingException
resolve
in interface ResolvableDeserializer
ctxt
- Context to use for accessing configuration, resolving
secondary deserializersJsonMappingException
public JsonDeserializer<?> createContextual(DeserializationContext ctxt, BeanProperty property) throws JsonMappingException
createContextual
in interface ContextualDeserializer
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)JsonMappingException
public AccessPattern getNullAccessPattern()
JsonDeserializer
JsonDeserializer.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 "null value" to use for input null is simply Java `null` for all deserializers, unless overridden by sub-classes. This information may be used as optimization.
getNullAccessPattern
in interface NullValueProvider
getNullAccessPattern
in class JsonDeserializer<java.lang.Object>
public AccessPattern getEmptyAccessPattern()
JsonDeserializer
JsonDeserializer.getEmptyValue(DeserializationContext)
, to check whether it needs
to be called just once (static values), or each time empty value is
needed.getEmptyAccessPattern
in class JsonDeserializer<java.lang.Object>
public java.lang.Object getEmptyValue(DeserializationContext ctxt) throws JsonMappingException
JsonDeserializer
JsonDeserializer.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.
getEmptyValue
in class JsonDeserializer<java.lang.Object>
JsonMappingException
public boolean isCachable()
JsonDeserializer
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.
isCachable
in class JsonDeserializer<java.lang.Object>
public java.lang.Boolean supportsUpdate(DeserializationConfig config)
JsonDeserializer
Boolean.FALSE
if update is not supported at all (immutable values);
Boolean.TRUE
if update should usually work (regular POJOs, for example),
or null
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 if Boolean.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.
supportsUpdate
in class JsonDeserializer<java.lang.Object>
public java.lang.Class<?> handledType()
JsonDeserializer
Default implementation will return null, which means almost same
same as returning Object.class
would; that is, that
nothing is known about handled type.
handledType
in class StdDeserializer<java.lang.Object>
public ObjectIdReader getObjectIdReader()
getObjectIdReader
in class JsonDeserializer<java.lang.Object>
public boolean hasProperty(java.lang.String propertyName)
public boolean hasViews()
public int getPropertyCount()
public java.util.Collection<java.lang.Object> getKnownPropertyNames()
JsonDeserializer
toString
will give external property
name.
This is only to be used for error reporting and diagnostics
purposes (most commonly, to accompany "unknown property"
exception).getKnownPropertyNames
in class JsonDeserializer<java.lang.Object>
@Deprecated public final java.lang.Class<?> getBeanClass()
handledType()
insteadpublic JavaType getValueType()
StdDeserializer
getValueType
in class StdDeserializer<java.lang.Object>
public java.util.Iterator<SettableBeanProperty> properties()
creatorProperties()
public java.util.Iterator<SettableBeanProperty> creatorProperties()
public SettableBeanProperty findProperty(PropertyName propertyName)
public SettableBeanProperty findProperty(java.lang.String propertyName)
public SettableBeanProperty findProperty(int propertyIndex)
property 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.public SettableBeanProperty findBackReference(java.lang.String logicalName)
BeanDeserializerFactory
to properly link
managed- and back-reference pairs.findBackReference
in class JsonDeserializer<java.lang.Object>
public ValueInstantiator getValueInstantiator()
getValueInstantiator
in interface ValueInstantiator.Gettable
public void replaceProperty(SettableBeanProperty original, SettableBeanProperty replacement)
NOTE: only ever use this method if you know what you are doing; incorrect usage can break deserializer.
original
- Property to replacereplacement
- Property to replace it withpublic abstract java.lang.Object deserializeFromObject(JsonParser p, DeserializationContext ctxt) throws java.io.IOException
java.io.IOException
public java.lang.Object deserializeWithType(JsonParser p, DeserializationContext ctxt, TypeDeserializer typeDeserializer) throws java.io.IOException
StdDeserializer
deserializeWithType
in class StdDeserializer<java.lang.Object>
typeDeserializer
- Deserializer to use for handling type informationjava.io.IOException
public java.lang.Object deserializeFromNumber(JsonParser p, DeserializationContext ctxt) throws java.io.IOException
java.io.IOException
public java.lang.Object deserializeFromString(JsonParser p, DeserializationContext ctxt) throws java.io.IOException
java.io.IOException
public java.lang.Object deserializeFromDouble(JsonParser p, DeserializationContext ctxt) throws java.io.IOException
java.io.IOException
public java.lang.Object deserializeFromBoolean(JsonParser p, DeserializationContext ctxt) throws java.io.IOException
java.io.IOException
public java.lang.Object deserializeFromArray(JsonParser p, DeserializationContext ctxt) throws java.io.IOException
java.io.IOException
public java.lang.Object deserializeFromEmbedded(JsonParser p, DeserializationContext ctxt) throws java.io.IOException
java.io.IOException
public void wrapAndThrow(java.lang.Throwable t, java.lang.Object bean, java.lang.String fieldName, DeserializationContext ctxt) throws java.io.IOException
IOException
, or an unchecked exception.
Rules for wrapping and unwrapping are bit complicated; essentially:
JsonMappingException
are to be passed as is
java.io.IOException
Copyright © 2010 - 2020 Adobe. All Rights Reserved