Class StdValueInstantiator
- java.lang.Object
-
- com.fasterxml.jackson.databind.deser.ValueInstantiator
-
- com.fasterxml.jackson.databind.deser.std.StdValueInstantiator
-
- All Implemented Interfaces:
java.io.Serializable
public class StdValueInstantiator extends ValueInstantiator implements java.io.Serializable
DefaultValueInstantiator
implementation, 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.Delegating, ValueInstantiator.Gettable
-
-
Constructor Summary
Constructors Constructor Description StdValueInstantiator(DeserializationConfig config, JavaType valueType)
StdValueInstantiator(DeserializationConfig config, java.lang.Class<?> valueType)
Deprecated.Since 2.7 use constructor that takesJavaType
instead
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
canCreateFromBigDecimal()
Method that can be called to check whether a BigDecimal based creator is available to use (to callValueInstantiator.createFromBigDecimal(com.fasterxml.jackson.databind.DeserializationContext, java.math.BigDecimal)
).boolean
canCreateFromBigInteger()
Method that can be called to check whether a BigInteger based creator is available to use (to callValueInstantiator.createFromBigInteger(com.fasterxml.jackson.databind.DeserializationContext, java.math.BigInteger)
).boolean
canCreateFromBoolean()
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)
).boolean
canCreateFromDouble()
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)
).boolean
canCreateFromInt()
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)
).boolean
canCreateFromLong()
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)
).boolean
canCreateFromObjectWith()
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 Objectboolean
canCreateFromString()
Method that can be called to check whether a String-based creator is available for this instantiator.boolean
canCreateUsingArrayDelegate()
Method that can be called to check whether a array-delegate-based creator (single-arg constructor or factory method) is available for this instantiatorboolean
canCreateUsingDefault()
Method that can be called to check whether a default creator (constructor, or no-arg static factory method) is available for this instantiatorboolean
canCreateUsingDelegate()
Method that can be called to check whether a delegate-based creator (single-arg constructor or factory method) is available for this instantiatorboolean
canInstantiate()
Method that will return true if any ofcanCreateXxx
method returns true: that is, if there is any way that an instance could be created.void
configureFromArraySettings(AnnotatedWithParams arrayDelegateCreator, JavaType arrayDelegateType, SettableBeanProperty[] arrayDelegateArgs)
void
configureFromBigDecimalCreator(AnnotatedWithParams creator)
void
configureFromBigIntegerCreator(AnnotatedWithParams creator)
void
configureFromBooleanCreator(AnnotatedWithParams creator)
void
configureFromDoubleCreator(AnnotatedWithParams creator)
void
configureFromIntCreator(AnnotatedWithParams creator)
void
configureFromLongCreator(AnnotatedWithParams creator)
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.void
configureFromStringCreator(AnnotatedWithParams creator)
java.lang.Object
createFromBigDecimal(DeserializationContext ctxt, java.math.BigDecimal value)
java.lang.Object
createFromBigInteger(DeserializationContext ctxt, java.math.BigInteger value)
java.lang.Object
createFromBoolean(DeserializationContext ctxt, boolean value)
java.lang.Object
createFromDouble(DeserializationContext ctxt, double value)
java.lang.Object
createFromInt(DeserializationContext ctxt, int value)
java.lang.Object
createFromLong(DeserializationContext ctxt, long value)
java.lang.Object
createFromObjectWith(DeserializationContext ctxt, java.lang.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.java.lang.Object
createFromString(DeserializationContext ctxt, java.lang.String value)
java.lang.Object
createUsingArrayDelegate(DeserializationContext ctxt, java.lang.Object delegate)
Method to called to create value instance from JSON Array using an intermediate "delegate" value to pass to createor methodjava.lang.Object
createUsingDefault(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.java.lang.Object
createUsingDelegate(DeserializationContext ctxt, java.lang.Object delegate)
Method to called to create value instance from JSON Object using an intermediate "delegate" value to pass to createor methodAnnotatedWithParams
getArrayDelegateCreator()
Method that can be called to try to access member (constructor, static factory method) that is used as the "array delegate creator".JavaType
getArrayDelegateType(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.AnnotatedWithParams
getDefaultCreator()
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).AnnotatedWithParams
getDelegateCreator()
Method that can be called to try to access member (constructor, static factory method) that is used as the "delegate creator".JavaType
getDelegateType(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).java.lang.Class<?>
getValueClass()
Accessor for raw (type-erased) type of instances to create.java.lang.String
getValueTypeDesc()
Method that returns description of the value type this instantiator handles.AnnotatedWithParams
getWithArgsCreator()
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).-
Methods inherited from class com.fasterxml.jackson.databind.deser.ValueInstantiator
createContextual, createFromObjectWith
-
-
-
-
Constructor Detail
-
StdValueInstantiator
@Deprecated public StdValueInstantiator(DeserializationConfig config, java.lang.Class<?> valueType)
Deprecated.Since 2.7 use constructor that takesJavaType
instead
-
StdValueInstantiator
public StdValueInstantiator(DeserializationConfig config, JavaType valueType)
-
-
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)
-
configureFromBigIntegerCreator
public void configureFromBigIntegerCreator(AnnotatedWithParams creator)
-
configureFromDoubleCreator
public void configureFromDoubleCreator(AnnotatedWithParams creator)
-
configureFromBigDecimalCreator
public void configureFromBigDecimalCreator(AnnotatedWithParams creator)
-
configureFromBooleanCreator
public void configureFromBooleanCreator(AnnotatedWithParams creator)
-
getValueTypeDesc
public java.lang.String getValueTypeDesc()
Description copied from class:ValueInstantiator
Method that returns description of the value type this instantiator handles. Used for error messages, diagnostics.- Overrides:
getValueTypeDesc
in classValueInstantiator
-
getValueClass
public java.lang.Class<?> getValueClass()
Description copied from class:ValueInstantiator
Accessor 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:
getValueClass
in classValueInstantiator
-
canCreateFromString
public boolean canCreateFromString()
Description copied from class:ValueInstantiator
Method that can be called to check whether a String-based creator is available for this instantiator.NOTE: does NOT include possible case of fallbacks, or coercion; only considers explicit creator.
- Overrides:
canCreateFromString
in classValueInstantiator
-
canCreateFromInt
public boolean canCreateFromInt()
Description copied from class:ValueInstantiator
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)
).- Overrides:
canCreateFromInt
in classValueInstantiator
-
canCreateFromLong
public boolean canCreateFromLong()
Description copied from class:ValueInstantiator
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)
).- Overrides:
canCreateFromLong
in classValueInstantiator
-
canCreateFromBigInteger
public boolean canCreateFromBigInteger()
Description copied from class:ValueInstantiator
Method that can be called to check whether a BigInteger based creator is available to use (to callValueInstantiator.createFromBigInteger(com.fasterxml.jackson.databind.DeserializationContext, java.math.BigInteger)
). +- Overrides:
canCreateFromBigInteger
in classValueInstantiator
-
canCreateFromDouble
public boolean canCreateFromDouble()
Description copied from class:ValueInstantiator
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)
).- Overrides:
canCreateFromDouble
in classValueInstantiator
-
canCreateFromBigDecimal
public boolean canCreateFromBigDecimal()
Description copied from class:ValueInstantiator
Method that can be called to check whether a BigDecimal based creator is available to use (to callValueInstantiator.createFromBigDecimal(com.fasterxml.jackson.databind.DeserializationContext, java.math.BigDecimal)
).- Overrides:
canCreateFromBigDecimal
in classValueInstantiator
-
canCreateFromBoolean
public boolean canCreateFromBoolean()
Description copied from class:ValueInstantiator
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)
).- Overrides:
canCreateFromBoolean
in classValueInstantiator
-
canCreateUsingDefault
public boolean canCreateUsingDefault()
Description copied from class:ValueInstantiator
Method that can be called to check whether a default creator (constructor, or no-arg static factory method) is available for this instantiator- Overrides:
canCreateUsingDefault
in classValueInstantiator
-
canCreateUsingDelegate
public boolean canCreateUsingDelegate()
Description copied from class:ValueInstantiator
Method that can be called to check whether a delegate-based creator (single-arg constructor or factory method) is available for this instantiator- Overrides:
canCreateUsingDelegate
in classValueInstantiator
-
canCreateUsingArrayDelegate
public boolean canCreateUsingArrayDelegate()
Description copied from class:ValueInstantiator
Method that can be called to check whether a array-delegate-based creator (single-arg constructor or factory method) is available for this instantiator- Overrides:
canCreateUsingArrayDelegate
in classValueInstantiator
-
canCreateFromObjectWith
public boolean canCreateFromObjectWith()
Description copied from class:ValueInstantiator
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 Object- Overrides:
canCreateFromObjectWith
in classValueInstantiator
-
canInstantiate
public boolean canInstantiate()
Description copied from class:ValueInstantiator
Method that will return true if any ofcanCreateXxx
method returns true: that is, if there is any way that an instance could be created.- Overrides:
canInstantiate
in classValueInstantiator
-
getDelegateType
public JavaType getDelegateType(DeserializationConfig config)
Description copied from class:ValueInstantiator
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. 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:
getDelegateType
in classValueInstantiator
-
getArrayDelegateType
public JavaType getArrayDelegateType(DeserializationConfig config)
Description copied from class:ValueInstantiator
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. 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:
getArrayDelegateType
in classValueInstantiator
-
getFromObjectArguments
public SettableBeanProperty[] getFromObjectArguments(DeserializationConfig config)
Description copied from class:ValueInstantiator
Method 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:
getFromObjectArguments
in classValueInstantiator
-
createUsingDefault
public java.lang.Object createUsingDefault(DeserializationContext ctxt) throws java.io.IOException
Description copied from class:ValueInstantiator
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. 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:
createUsingDefault
in classValueInstantiator
- Throws:
java.io.IOException
-
createFromObjectWith
public java.lang.Object createFromObjectWith(DeserializationContext ctxt, java.lang.Object[] args) throws java.io.IOException
Description copied from class:ValueInstantiator
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.This method is called if
ValueInstantiator.getFromObjectArguments(com.fasterxml.jackson.databind.DeserializationConfig)
returns a non-empty List of arguments.- Overrides:
createFromObjectWith
in classValueInstantiator
- Throws:
java.io.IOException
-
createUsingDelegate
public java.lang.Object createUsingDelegate(DeserializationContext ctxt, java.lang.Object delegate) throws java.io.IOException
Description copied from class:ValueInstantiator
Method to called to create value instance from JSON Object using an intermediate "delegate" value to pass to createor method- Overrides:
createUsingDelegate
in classValueInstantiator
- Throws:
java.io.IOException
-
createUsingArrayDelegate
public java.lang.Object createUsingArrayDelegate(DeserializationContext ctxt, java.lang.Object delegate) throws java.io.IOException
Description copied from class:ValueInstantiator
Method to called to create value instance from JSON Array using an intermediate "delegate" value to pass to createor method- Overrides:
createUsingArrayDelegate
in classValueInstantiator
- Throws:
java.io.IOException
-
createFromString
public java.lang.Object createFromString(DeserializationContext ctxt, java.lang.String value) throws java.io.IOException
- Overrides:
createFromString
in classValueInstantiator
- Throws:
java.io.IOException
-
createFromInt
public java.lang.Object createFromInt(DeserializationContext ctxt, int value) throws java.io.IOException
- Overrides:
createFromInt
in classValueInstantiator
- Throws:
java.io.IOException
-
createFromLong
public java.lang.Object createFromLong(DeserializationContext ctxt, long value) throws java.io.IOException
- Overrides:
createFromLong
in classValueInstantiator
- Throws:
java.io.IOException
-
createFromBigInteger
public java.lang.Object createFromBigInteger(DeserializationContext ctxt, java.math.BigInteger value) throws java.io.IOException
- Overrides:
createFromBigInteger
in classValueInstantiator
- Throws:
java.io.IOException
-
createFromDouble
public java.lang.Object createFromDouble(DeserializationContext ctxt, double value) throws java.io.IOException
- Overrides:
createFromDouble
in classValueInstantiator
- Throws:
java.io.IOException
-
createFromBigDecimal
public java.lang.Object createFromBigDecimal(DeserializationContext ctxt, java.math.BigDecimal value) throws java.io.IOException
- Overrides:
createFromBigDecimal
in classValueInstantiator
- Throws:
java.io.IOException
-
createFromBoolean
public java.lang.Object createFromBoolean(DeserializationContext ctxt, boolean value) throws java.io.IOException
- Overrides:
createFromBoolean
in classValueInstantiator
- Throws:
java.io.IOException
-
getDelegateCreator
public AnnotatedWithParams getDelegateCreator()
Description copied from class:ValueInstantiator
Method 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:
getDelegateCreator
in classValueInstantiator
-
getArrayDelegateCreator
public AnnotatedWithParams getArrayDelegateCreator()
Description copied from class:ValueInstantiator
Method 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:
getArrayDelegateCreator
in classValueInstantiator
-
getDefaultCreator
public AnnotatedWithParams getDefaultCreator()
Description copied from class:ValueInstantiator
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). 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:
getDefaultCreator
in classValueInstantiator
-
getWithArgsCreator
public AnnotatedWithParams getWithArgsCreator()
Description copied from class:ValueInstantiator
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). 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:
getWithArgsCreator
in classValueInstantiator
-
-