Class StdValueInstantiator
- java.lang.Object
-
- com.fasterxml.jackson.databind.deser.ValueInstantiator
-
- com.fasterxml.jackson.databind.deser.std.StdValueInstantiator
-
- All Implemented Interfaces:
Serializable
public class StdValueInstantiator extends ValueInstantiator implements Serializable
DefaultValueInstantiatorimplementation, which supports Creator methods that can be indicated by standard Jackson annotations.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.fasterxml.jackson.databind.deser.ValueInstantiator
ValueInstantiator.Base, ValueInstantiator.Gettable
-
-
Field Summary
-
Constructor Summary
Constructors Modifier Constructor Description protectedStdValueInstantiator(StdValueInstantiator src)Copy-constructor that sub-classes can use when creating new instances by fluent-style constructionStdValueInstantiator(DeserializationConfig config, JavaType valueType)StdValueInstantiator(DeserializationConfig config, Class<?> valueType)Deprecated.Since 2.7 use constructor that takesJavaTypeinstead
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description booleancanCreateFromBoolean()Method that can be called to check whether a double (boolean / Boolean) based creator is available to use (to callValueInstantiator.createFromDouble(com.fasterxml.jackson.databind.DeserializationContext, double)).booleancanCreateFromDouble()Method that can be called to check whether a double (double / Double) based creator is available to use (to callValueInstantiator.createFromDouble(com.fasterxml.jackson.databind.DeserializationContext, double)).booleancanCreateFromInt()Method that can be called to check whether an integer (int, Integer) based creator is available to use (to callValueInstantiator.createFromInt(com.fasterxml.jackson.databind.DeserializationContext, int)).booleancanCreateFromLong()Method that can be called to check whether a long (long, Long) based creator is available to use (to callValueInstantiator.createFromLong(com.fasterxml.jackson.databind.DeserializationContext, long)).booleancanCreateFromObjectWith()Method that can be called to check whether a property-based creator (argument-taking constructor or factory method) is available to instantiate values from JSON ObjectbooleancanCreateFromString()Method that can be called to check whether a String-based creator is available for this instantiatorbooleancanCreateUsingArrayDelegate()Method that can be called to check whether a array-delegate-based creator (single-arg constructor or factory method) is available for this instantiatorbooleancanCreateUsingDefault()Method that can be called to check whether a default creator (constructor, or no-arg static factory method) is available for this instantiatorbooleancanCreateUsingDelegate()Method that can be called to check whether a delegate-based creator (single-arg constructor or factory method) is available for this instantiatorbooleancanInstantiate()Method that will return true if any ofcanCreateXxxmethod returns true: that is, if there is any way that an instance could be created.voidconfigureFromArraySettings(AnnotatedWithParams arrayDelegateCreator, JavaType arrayDelegateType, SettableBeanProperty[] arrayDelegateArgs)voidconfigureFromBooleanCreator(AnnotatedWithParams creator)voidconfigureFromDoubleCreator(AnnotatedWithParams creator)voidconfigureFromIntCreator(AnnotatedWithParams creator)voidconfigureFromLongCreator(AnnotatedWithParams creator)voidconfigureFromObjectSettings(AnnotatedWithParams defaultCreator, AnnotatedWithParams delegateCreator, JavaType delegateType, SettableBeanProperty[] delegateArgs, AnnotatedWithParams withArgsCreator, SettableBeanProperty[] constructorArgs)Method for setting properties related to instantiating values from JSON Object.voidconfigureFromStringCreator(AnnotatedWithParams creator)voidconfigureIncompleteParameter(AnnotatedParameter parameter)ObjectcreateFromBoolean(DeserializationContext ctxt, boolean value)ObjectcreateFromDouble(DeserializationContext ctxt, double value)ObjectcreateFromInt(DeserializationContext ctxt, int value)ObjectcreateFromLong(DeserializationContext ctxt, long value)ObjectcreateFromObjectWith(DeserializationContext ctxt, Object[] args)Method called to create value instance from JSON Object when instantiation arguments are passed; this is done, for example when passing information specified with "Creator" annotations.ObjectcreateFromString(DeserializationContext ctxt, String value)ObjectcreateUsingArrayDelegate(DeserializationContext ctxt, Object delegate)Method to called to create value instance from JSON Array using an intermediate "delegate" value to pass to createor methodObjectcreateUsingDefault(DeserializationContext ctxt)Method called to create value instance from a JSON value when no data needs to passed to creator (constructor, factory method); typically this will call the default constructor of the value object.ObjectcreateUsingDelegate(DeserializationContext ctxt, Object delegate)Method to called to create value instance from JSON Object using an intermediate "delegate" value to pass to createor methodAnnotatedWithParamsgetArrayDelegateCreator()Method that can be called to try to access member (constructor, static factory method) that is used as the "array delegate creator".JavaTypegetArrayDelegateType(DeserializationConfig config)Method that can be used to determine what is the type of array delegate type to use, if any; if no delegates are used, will return null.AnnotatedWithParamsgetDefaultCreator()Method that can be called to try to access member (constructor, static factory method) that is used as the "default creator" (creator that is called without arguments; typically default [zero-argument] constructor of the type).AnnotatedWithParamsgetDelegateCreator()Method that can be called to try to access member (constructor, static factory method) that is used as the "delegate creator".JavaTypegetDelegateType(DeserializationConfig config)Method that can be used to determine what is the type of delegate type to use, if any; if no delegates are used, will return null.SettableBeanProperty[]getFromObjectArguments(DeserializationConfig config)Method called to determine types of instantiation arguments to use when creating instances with creator arguments (whenValueInstantiator.canCreateFromObjectWith()returns true).AnnotatedParametergetIncompleteParameter()If an incomplete creator was found, this is the first parameter that needs further annotation to help make the creator complete.Class<?>getValueClass()Accessor for raw (type-erased) type of instances to create.StringgetValueTypeDesc()Method that returns description of the value type this instantiator handles.AnnotatedWithParamsgetWithArgsCreator()Method that can be called to try to access member (constructor, static factory method) that is used as the "non-default creator" (constructor or factory method that takes one or more arguments).protected JsonMappingExceptionrewrapCtorProblem(DeserializationContext ctxt, Throwable t)Method that subclasses may call for standard handling of an exception thrown when calling constructor or factory method.protected JsonMappingExceptionunwrapAndWrapException(DeserializationContext ctxt, Throwable t)protected JsonMappingExceptionwrapAsJsonMappingException(DeserializationContext ctxt, Throwable t)Helper method that will return givenThrowablecase as aJsonMappingException(if it is of that type), or callDeserializationContext.instantiationException(Class, Throwable)to produce and return suitableJsonMappingException.protected JsonMappingExceptionwrapException(Throwable t)-
Methods inherited from class com.fasterxml.jackson.databind.deser.ValueInstantiator
_createFromStringFallbacks, createFromObjectWith
-
-
-
-
Field Detail
-
_valueTypeDesc
protected final String _valueTypeDesc
Type of values that are instantiated; used for error reporting purposes.
-
_valueClass
protected final Class<?> _valueClass
- Since:
- 2.8
-
_defaultCreator
protected AnnotatedWithParams _defaultCreator
Default (no-argument) constructor to use for instantiation (withcreateUsingDefault(com.fasterxml.jackson.databind.DeserializationContext))
-
_withArgsCreator
protected AnnotatedWithParams _withArgsCreator
-
_constructorArguments
protected SettableBeanProperty[] _constructorArguments
-
_delegateType
protected JavaType _delegateType
-
_delegateCreator
protected AnnotatedWithParams _delegateCreator
-
_delegateArguments
protected SettableBeanProperty[] _delegateArguments
-
_arrayDelegateType
protected JavaType _arrayDelegateType
-
_arrayDelegateCreator
protected AnnotatedWithParams _arrayDelegateCreator
-
_arrayDelegateArguments
protected SettableBeanProperty[] _arrayDelegateArguments
-
_fromStringCreator
protected AnnotatedWithParams _fromStringCreator
-
_fromIntCreator
protected AnnotatedWithParams _fromIntCreator
-
_fromLongCreator
protected AnnotatedWithParams _fromLongCreator
-
_fromDoubleCreator
protected AnnotatedWithParams _fromDoubleCreator
-
_fromBooleanCreator
protected AnnotatedWithParams _fromBooleanCreator
-
_incompleteParameter
protected AnnotatedParameter _incompleteParameter
-
-
Constructor Detail
-
StdValueInstantiator
@Deprecated public StdValueInstantiator(DeserializationConfig config, Class<?> valueType)
Deprecated.Since 2.7 use constructor that takesJavaTypeinstead
-
StdValueInstantiator
public StdValueInstantiator(DeserializationConfig config, JavaType valueType)
-
StdValueInstantiator
protected StdValueInstantiator(StdValueInstantiator src)
Copy-constructor that sub-classes can use when creating new instances by fluent-style construction
-
-
Method Detail
-
configureFromObjectSettings
public void configureFromObjectSettings(AnnotatedWithParams defaultCreator, AnnotatedWithParams delegateCreator, JavaType delegateType, SettableBeanProperty[] delegateArgs, AnnotatedWithParams withArgsCreator, SettableBeanProperty[] constructorArgs)
Method for setting properties related to instantiating values from JSON Object. We will choose basically only one approach (out of possible three), and clear other properties
-
configureFromArraySettings
public void configureFromArraySettings(AnnotatedWithParams arrayDelegateCreator, JavaType arrayDelegateType, SettableBeanProperty[] arrayDelegateArgs)
-
configureFromStringCreator
public void configureFromStringCreator(AnnotatedWithParams creator)
-
configureFromIntCreator
public void configureFromIntCreator(AnnotatedWithParams creator)
-
configureFromLongCreator
public void configureFromLongCreator(AnnotatedWithParams creator)
-
configureFromDoubleCreator
public void configureFromDoubleCreator(AnnotatedWithParams creator)
-
configureFromBooleanCreator
public void configureFromBooleanCreator(AnnotatedWithParams creator)
-
configureIncompleteParameter
public void configureIncompleteParameter(AnnotatedParameter parameter)
-
getValueTypeDesc
public String getValueTypeDesc()
Description copied from class:ValueInstantiatorMethod that returns description of the value type this instantiator handles. Used for error messages, diagnostics.- Overrides:
getValueTypeDescin classValueInstantiator
-
getValueClass
public Class<?> getValueClass()
Description copied from class:ValueInstantiatorAccessor for raw (type-erased) type of instances to create.NOTE: since this method has not existed since beginning of Jackson 2.0 series, default implementation will just return
Object.class; implementations are expected to override it with real value.- Overrides:
getValueClassin classValueInstantiator
-
canCreateFromString
public boolean canCreateFromString()
Description copied from class:ValueInstantiatorMethod that can be called to check whether a String-based creator is available for this instantiator- Overrides:
canCreateFromStringin classValueInstantiator
-
canCreateFromInt
public boolean canCreateFromInt()
Description copied from class:ValueInstantiatorMethod that can be called to check whether an integer (int, Integer) based creator is available to use (to callValueInstantiator.createFromInt(com.fasterxml.jackson.databind.DeserializationContext, int)).- Overrides:
canCreateFromIntin classValueInstantiator
-
canCreateFromLong
public boolean canCreateFromLong()
Description copied from class:ValueInstantiatorMethod that can be called to check whether a long (long, Long) based creator is available to use (to callValueInstantiator.createFromLong(com.fasterxml.jackson.databind.DeserializationContext, long)).- Overrides:
canCreateFromLongin classValueInstantiator
-
canCreateFromDouble
public boolean canCreateFromDouble()
Description copied from class:ValueInstantiatorMethod that can be called to check whether a double (double / Double) based creator is available to use (to callValueInstantiator.createFromDouble(com.fasterxml.jackson.databind.DeserializationContext, double)).- Overrides:
canCreateFromDoublein classValueInstantiator
-
canCreateFromBoolean
public boolean canCreateFromBoolean()
Description copied from class:ValueInstantiatorMethod that can be called to check whether a double (boolean / Boolean) based creator is available to use (to callValueInstantiator.createFromDouble(com.fasterxml.jackson.databind.DeserializationContext, double)).- Overrides:
canCreateFromBooleanin classValueInstantiator
-
canCreateUsingDefault
public boolean canCreateUsingDefault()
Description copied from class:ValueInstantiatorMethod that can be called to check whether a default creator (constructor, or no-arg static factory method) is available for this instantiator- Overrides:
canCreateUsingDefaultin classValueInstantiator
-
canCreateUsingDelegate
public boolean canCreateUsingDelegate()
Description copied from class:ValueInstantiatorMethod that can be called to check whether a delegate-based creator (single-arg constructor or factory method) is available for this instantiator- Overrides:
canCreateUsingDelegatein classValueInstantiator
-
canCreateUsingArrayDelegate
public boolean canCreateUsingArrayDelegate()
Description copied from class:ValueInstantiatorMethod that can be called to check whether a array-delegate-based creator (single-arg constructor or factory method) is available for this instantiator- Overrides:
canCreateUsingArrayDelegatein classValueInstantiator
-
canCreateFromObjectWith
public boolean canCreateFromObjectWith()
Description copied from class:ValueInstantiatorMethod that can be called to check whether a property-based creator (argument-taking constructor or factory method) is available to instantiate values from JSON Object- Overrides:
canCreateFromObjectWithin classValueInstantiator
-
canInstantiate
public boolean canInstantiate()
Description copied from class:ValueInstantiatorMethod that will return true if any ofcanCreateXxxmethod returns true: that is, if there is any way that an instance could be created.- Overrides:
canInstantiatein classValueInstantiator
-
getDelegateType
public JavaType getDelegateType(DeserializationConfig config)
Description copied from class:ValueInstantiatorMethod that can be used to determine what is the type of delegate type to use, if any; if no delegates are used, will return null. If non-null type is returned, deserializer will bind JSON into specified type (using standard deserializer for that type), and pass that to instantiator.- Overrides:
getDelegateTypein classValueInstantiator
-
getArrayDelegateType
public JavaType getArrayDelegateType(DeserializationConfig config)
Description copied from class:ValueInstantiatorMethod that can be used to determine what is the type of array delegate type to use, if any; if no delegates are used, will return null. If non-null type is returned, deserializer will bind JSON into specified type (using standard deserializer for that type), and pass that to instantiator.- Overrides:
getArrayDelegateTypein classValueInstantiator
-
getFromObjectArguments
public SettableBeanProperty[] getFromObjectArguments(DeserializationConfig config)
Description copied from class:ValueInstantiatorMethod called to determine types of instantiation arguments to use when creating instances with creator arguments (whenValueInstantiator.canCreateFromObjectWith()returns true). These arguments are bound from JSON, using specified property types to locate deserializers.NOTE: all properties will be of type
CreatorProperty.- Overrides:
getFromObjectArgumentsin classValueInstantiator
-
createUsingDefault
public Object createUsingDefault(DeserializationContext ctxt) throws IOException
Description copied from class:ValueInstantiatorMethod called to create value instance from a JSON value when no data needs to passed to creator (constructor, factory method); typically this will call the default constructor of the value object. It will only be used if more specific creator methods are not applicable; hence "default".This method is called if
ValueInstantiator.getFromObjectArguments(com.fasterxml.jackson.databind.DeserializationConfig)returns null or empty List.- Overrides:
createUsingDefaultin classValueInstantiator- Throws:
IOException
-
createFromObjectWith
public Object createFromObjectWith(DeserializationContext ctxt, Object[] args) throws IOException
Description copied from class:ValueInstantiatorMethod called to create value instance from JSON Object when instantiation arguments are passed; this is done, for example when passing information specified with "Creator" annotations.This method is called if
ValueInstantiator.getFromObjectArguments(com.fasterxml.jackson.databind.DeserializationConfig)returns a non-empty List of arguments.- Overrides:
createFromObjectWithin classValueInstantiator- Throws:
IOException
-
createUsingDelegate
public Object createUsingDelegate(DeserializationContext ctxt, Object delegate) throws IOException
Description copied from class:ValueInstantiatorMethod to called to create value instance from JSON Object using an intermediate "delegate" value to pass to createor method- Overrides:
createUsingDelegatein classValueInstantiator- Throws:
IOException
-
createUsingArrayDelegate
public Object createUsingArrayDelegate(DeserializationContext ctxt, Object delegate) throws IOException
Description copied from class:ValueInstantiatorMethod to called to create value instance from JSON Array using an intermediate "delegate" value to pass to createor method- Overrides:
createUsingArrayDelegatein classValueInstantiator- Throws:
IOException
-
createFromString
public Object createFromString(DeserializationContext ctxt, String value) throws IOException
- Overrides:
createFromStringin classValueInstantiator- Throws:
IOException
-
createFromInt
public Object createFromInt(DeserializationContext ctxt, int value) throws IOException
- Overrides:
createFromIntin classValueInstantiator- Throws:
IOException
-
createFromLong
public Object createFromLong(DeserializationContext ctxt, long value) throws IOException
- Overrides:
createFromLongin classValueInstantiator- Throws:
IOException
-
createFromDouble
public Object createFromDouble(DeserializationContext ctxt, double value) throws IOException
- Overrides:
createFromDoublein classValueInstantiator- Throws:
IOException
-
createFromBoolean
public Object createFromBoolean(DeserializationContext ctxt, boolean value) throws IOException
- Overrides:
createFromBooleanin classValueInstantiator- Throws:
IOException
-
getDelegateCreator
public AnnotatedWithParams getDelegateCreator()
Description copied from class:ValueInstantiatorMethod that can be called to try to access member (constructor, static factory method) that is used as the "delegate creator". Note that implementations not required to return actual object they use (or, they may use some other instantiation) method. That is, even ifValueInstantiator.canCreateUsingDelegate()returns true, this method may return null .- Overrides:
getDelegateCreatorin classValueInstantiator
-
getArrayDelegateCreator
public AnnotatedWithParams getArrayDelegateCreator()
Description copied from class:ValueInstantiatorMethod that can be called to try to access member (constructor, static factory method) that is used as the "array delegate creator". Note that implementations not required to return actual object they use (or, they may use some other instantiation) method. That is, even ifValueInstantiator.canCreateUsingArrayDelegate()returns true, this method may return null .- Overrides:
getArrayDelegateCreatorin classValueInstantiator
-
getDefaultCreator
public AnnotatedWithParams getDefaultCreator()
Description copied from class:ValueInstantiatorMethod that can be called to try to access member (constructor, static factory method) that is used as the "default creator" (creator that is called without arguments; typically default [zero-argument] constructor of the type). Note that implementations not required to return actual object they use (or, they may use some other instantiation) method. That is, even ifValueInstantiator.canCreateUsingDefault()returns true, this method may return null .- Overrides:
getDefaultCreatorin classValueInstantiator
-
getWithArgsCreator
public AnnotatedWithParams getWithArgsCreator()
Description copied from class:ValueInstantiatorMethod that can be called to try to access member (constructor, static factory method) that is used as the "non-default creator" (constructor or factory method that takes one or more arguments). Note that implementations not required to return actual object they use (or, they may use some other instantiation) method. That is, even ifValueInstantiator.canCreateFromObjectWith()returns true, this method may return null .- Overrides:
getWithArgsCreatorin classValueInstantiator
-
getIncompleteParameter
public AnnotatedParameter getIncompleteParameter()
Description copied from class:ValueInstantiatorIf an incomplete creator was found, this is the first parameter that needs further annotation to help make the creator complete.- Overrides:
getIncompleteParameterin classValueInstantiator
-
wrapException
@Deprecated protected JsonMappingException wrapException(Throwable t)
-
unwrapAndWrapException
@Deprecated protected JsonMappingException unwrapAndWrapException(DeserializationContext ctxt, Throwable t)
-
wrapAsJsonMappingException
protected JsonMappingException wrapAsJsonMappingException(DeserializationContext ctxt, Throwable t)
Helper method that will return givenThrowablecase as aJsonMappingException(if it is of that type), or callDeserializationContext.instantiationException(Class, Throwable)to produce and return suitableJsonMappingException.- Since:
- 2.7
-
rewrapCtorProblem
protected JsonMappingException rewrapCtorProblem(DeserializationContext ctxt, Throwable t)
Method that subclasses may call for standard handling of an exception thrown when calling constructor or factory method. Will unwrapExceptionInInitializerErrorandInvocationTargetExceptions, then callwrapAsJsonMappingException(com.fasterxml.jackson.databind.DeserializationContext, java.lang.Throwable).- Since:
- 2.7
-
-