Class ValueInstantiator
- Direct Known Subclasses:
StdValueInstantiator
,ValueInstantiator.Base
,ValueInstantiator.Delegating
Note that this type is not parameterized (even though it would seemingly
make sense), because such type information cannot be use effectively
during runtime: access is always using either wildcard type, or just
basic Object
; and so adding type parameter seems
like unnecessary extra work.
Actual implementations are strongly recommended to be based on
StdValueInstantiator
which implements all methods, and as such will be compatible
across versions even if new methods were added to this interface.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
PartialValueInstantiator
implementation that is strongly recommended to be used instead of directly extendingValueInstantiator
itself.static class
DelegatingValueInstantiator
implementation meant as a base type that by default delegates methods to specified fallback instantiator.static interface
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
Method that can be called to check whether a BigDecimal based creator is available to use (to callcreateFromBigDecimal(com.fasterxml.jackson.databind.DeserializationContext, java.math.BigDecimal)
).boolean
Method that can be called to check whether a BigInteger based creator is available to use (to callcreateFromBigInteger(com.fasterxml.jackson.databind.DeserializationContext, java.math.BigInteger)
).boolean
Method that can be called to check whether a double (boolean / Boolean) based creator is available to use (to callcreateFromDouble(com.fasterxml.jackson.databind.DeserializationContext, double)
).boolean
Method that can be called to check whether a double (double / Double) based creator is available to use (to callcreateFromDouble(com.fasterxml.jackson.databind.DeserializationContext, double)
).boolean
Method that can be called to check whether an integer (int, Integer) based creator is available to use (to callcreateFromInt(com.fasterxml.jackson.databind.DeserializationContext, int)
).boolean
Method that can be called to check whether a long (long, Long) based creator is available to use (to callcreateFromLong(com.fasterxml.jackson.databind.DeserializationContext, long)
).boolean
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
Method that can be called to check whether a String-based creator is available for this instantiator.boolean
Method that can be called to check whether a array-delegate-based creator (single-arg constructor or factory method) is available for this instantiatorboolean
Method that can be called to check whether a default creator (constructor, or no-arg static factory method) is available for this instantiatorboolean
Method that can be called to check whether a delegate-based creator (single-arg constructor or factory method) is available for this instantiatorboolean
Method that will return true if any ofcanCreateXxx
method returns true: that is, if there is any way that an instance could be created.createContextual
(DeserializationContext ctxt, BeanDescription beanDesc) "Contextualization" method that is called after construction but before first use, to allow instantiator access to context needed to possible resolve its dependencies.createFromBigDecimal
(DeserializationContext ctxt, BigDecimal value) createFromBigInteger
(DeserializationContext ctxt, BigInteger value) createFromBoolean
(DeserializationContext ctxt, boolean value) createFromDouble
(DeserializationContext ctxt, double value) createFromInt
(DeserializationContext ctxt, int value) createFromLong
(DeserializationContext ctxt, long value) createFromObjectWith
(DeserializationContext ctxt, SettableBeanProperty[] props, PropertyValueBuffer buffer) Method that delegates tocreateFromObjectWith(DeserializationContext, Object[])
by default, but can be overridden if the application should have customized behavior with respect to missing properties.createFromObjectWith
(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.createFromString
(DeserializationContext ctxt, String value) createUsingArrayDelegate
(DeserializationContext ctxt, Object delegate) Method to called to create value instance from JSON Array using an intermediate "delegate" value to pass to createor methodMethod 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.Combination ofcreateUsingDefault(com.fasterxml.jackson.databind.DeserializationContext)
andcreateFromObjectWith(DeserializationContext, Object[])
which will call former first, if possible; or latter if possible (withnull
arguments); and if neither works throw an exception.createUsingDelegate
(DeserializationContext ctxt, Object delegate) Method to called to create value instance from JSON Object using an intermediate "delegate" value to pass to createor methodMethod that can be called to try to access member (constructor, static factory method) that is used as the "array delegate creator".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.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).Method that can be called to try to access member (constructor, static factory method) that is used as the "delegate creator".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.Method called to determine types of instantiation arguments to use when creating instances with creator arguments (whencanCreateFromObjectWith()
returns true).Class
<?> Accessor for raw (type-erased) type of instances to create.Method that returns description of the value type this instantiator handles.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).
-
Constructor Details
-
ValueInstantiator
public ValueInstantiator()
-
-
Method Details
-
createContextual
public ValueInstantiator createContextual(DeserializationContext ctxt, BeanDescription beanDesc) throws JsonMappingException "Contextualization" method that is called after construction but before first use, to allow instantiator access to context needed to possible resolve its dependencies.- Parameters:
ctxt
- Currently active deserialization context: needed to (for example) resolvingTypeDeserializer
s.- Returns:
- This instance, if no change, or newly constructed instance
- Throws:
JsonMappingException
- If there are issues with contextualization- Since:
- 2.12
-
getValueClass
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.- Since:
- 2.8
-
getValueTypeDesc
Method that returns description of the value type this instantiator handles. Used for error messages, diagnostics. -
canInstantiate
public boolean 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. -
canCreateFromString
public boolean canCreateFromString()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.
-
canCreateFromInt
public boolean canCreateFromInt()Method that can be called to check whether an integer (int, Integer) based creator is available to use (to callcreateFromInt(com.fasterxml.jackson.databind.DeserializationContext, int)
). -
canCreateFromLong
public boolean canCreateFromLong()Method that can be called to check whether a long (long, Long) based creator is available to use (to callcreateFromLong(com.fasterxml.jackson.databind.DeserializationContext, long)
). -
canCreateFromBigInteger
public boolean canCreateFromBigInteger()Method that can be called to check whether a BigInteger based creator is available to use (to callcreateFromBigInteger(com.fasterxml.jackson.databind.DeserializationContext, java.math.BigInteger)
). + -
canCreateFromDouble
public boolean canCreateFromDouble()Method that can be called to check whether a double (double / Double) based creator is available to use (to callcreateFromDouble(com.fasterxml.jackson.databind.DeserializationContext, double)
). -
canCreateFromBigDecimal
public boolean canCreateFromBigDecimal()Method that can be called to check whether a BigDecimal based creator is available to use (to callcreateFromBigDecimal(com.fasterxml.jackson.databind.DeserializationContext, java.math.BigDecimal)
). -
canCreateFromBoolean
public boolean canCreateFromBoolean()Method that can be called to check whether a double (boolean / Boolean) based creator is available to use (to callcreateFromDouble(com.fasterxml.jackson.databind.DeserializationContext, double)
). -
canCreateUsingDefault
public boolean canCreateUsingDefault()Method that can be called to check whether a default creator (constructor, or no-arg static factory method) is available for this instantiator -
canCreateUsingDelegate
public boolean canCreateUsingDelegate()Method that can be called to check whether a delegate-based creator (single-arg constructor or factory method) is available for this instantiator -
canCreateUsingArrayDelegate
public 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 instantiator- Since:
- 2.7
-
canCreateFromObjectWith
public 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 Object -
getFromObjectArguments
Method called to determine types of instantiation arguments to use when creating instances with creator arguments (whencanCreateFromObjectWith()
returns true). These arguments are bound from JSON, using specified property types to locate deserializers.NOTE: all properties will be of type
CreatorProperty
. -
getDelegateType
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. -
getArrayDelegateType
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.- Since:
- 2.7
-
createUsingDefault
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
getFromObjectArguments(com.fasterxml.jackson.databind.DeserializationConfig)
returns null or empty List.- Throws:
IOException
-
createFromObjectWith
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
getFromObjectArguments(com.fasterxml.jackson.databind.DeserializationConfig)
returns a non-empty List of arguments.- Throws:
IOException
-
createUsingDefaultOrWithoutArguments
Combination ofcreateUsingDefault(com.fasterxml.jackson.databind.DeserializationContext)
andcreateFromObjectWith(DeserializationContext, Object[])
which will call former first, if possible; or latter if possible (withnull
arguments); and if neither works throw an exception.- Throws:
IOException
- Since:
- 2.15
-
createFromObjectWith
public Object createFromObjectWith(DeserializationContext ctxt, SettableBeanProperty[] props, PropertyValueBuffer buffer) throws IOException Method that delegates tocreateFromObjectWith(DeserializationContext, Object[])
by default, but can be overridden if the application should have customized behavior with respect to missing properties.The default implementation of this method uses
PropertyValueBuffer.getParameters(SettableBeanProperty[])
to read and validate all properties in bulk, possibly substituting defaults for missing properties or throwing exceptions for missing properties. An overridden implementation of this method could, for example, usePropertyValueBuffer.hasParameter(SettableBeanProperty)
andPropertyValueBuffer.getParameter(SettableBeanProperty)
to safely read the present properties only, and to have some other behavior for the missing properties.- Throws:
IOException
- Since:
- 2.8
-
createUsingDelegate
Method to called to create value instance from JSON Object using an intermediate "delegate" value to pass to createor method- Throws:
IOException
-
createUsingArrayDelegate
public Object createUsingArrayDelegate(DeserializationContext ctxt, Object delegate) throws IOException Method to called to create value instance from JSON Array using an intermediate "delegate" value to pass to createor method- Throws:
IOException
-
createFromString
- Throws:
IOException
-
createFromInt
- Throws:
IOException
-
createFromLong
- Throws:
IOException
-
createFromBigInteger
public Object createFromBigInteger(DeserializationContext ctxt, BigInteger value) throws IOException - Throws:
IOException
-
createFromDouble
- Throws:
IOException
-
createFromBigDecimal
public Object createFromBigDecimal(DeserializationContext ctxt, BigDecimal value) throws IOException - Throws:
IOException
-
createFromBoolean
- Throws:
IOException
-
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). Note that implementations not required to return actual object they use (or, they may use some other instantiation) method. That is, even ifcanCreateUsingDefault()
returns true, this method may return null . -
getDelegateCreator
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 ifcanCreateUsingDelegate()
returns true, this method may return null . -
getArrayDelegateCreator
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 ifcanCreateUsingArrayDelegate()
returns true, this method may return null . -
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). Note that implementations not required to return actual object they use (or, they may use some other instantiation) method. That is, even ifcanCreateFromObjectWith()
returns true, this method may return null .
-