Class StdValueInstantiator
java.lang.Object
org.codehaus.jackson.map.deser.ValueInstantiator
org.codehaus.jackson.map.deser.std.StdValueInstantiator
Basic
ValueInstantiator implementation, which only
supports use of default constructor. Sub-types can add
support for alternate construction methods, such as using
argument-taking constructors or static factory methods.- Since:
- 1.9.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final booleanAre we allowed to convert empty Strings to null objects?protected CreatorProperty[]protected AnnotatedWithParamsDefault (no-argument) constructor to use for instantiation (withcreateUsingDefault())protected AnnotatedWithParamsprotected JavaTypeprotected AnnotatedWithParamsprotected AnnotatedWithParamsprotected AnnotatedWithParamsprotected AnnotatedWithParamsprotected AnnotatedWithParamsprotected final StringType of values that are instantiated; used for error reporting purposes.protected AnnotatedWithParams -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCopy-constructor that sub-classes can use when creating new instances by fluent-style constructionStdValueInstantiator(DeserializationConfig config, Class<?> valueType) StdValueInstantiator(DeserializationConfig config, JavaType valueType) -
Method Summary
Modifier and TypeMethodDescriptionprotected Object_createFromStringFallbacks(String value) booleanMethod that can be called to check whether a double (boolean / Boolean) based creator is available to use (to callValueInstantiator.createFromDouble(double)).booleanMethod that can be called to check whether a double (double / Double) based creator is available to use (to callValueInstantiator.createFromDouble(double)).booleanMethod that can be called to check whether an integer (int, Integer) based creator is available to use (to callValueInstantiator.createFromInt(int)).booleanMethod that can be called to check whether a long (long, Long) based creator is available to use (to callValueInstantiator.createFromLong(long)).booleanMethod that can be called to check whether a property-based creator (argument-taking constructor or factory method) is available to instantiate values from JSON ObjectbooleanMethod that can be called to check whether a String-based creator is available for this instantiatorbooleanMethod that can be called to check whether a default creator (constructor, or no-arg static factory method) is available for this instantiatorvoidvoidvoidvoidvoidconfigureFromObjectSettings(AnnotatedWithParams defaultCreator, AnnotatedWithParams delegateCreator, JavaType delegateType, AnnotatedWithParams withArgsCreator, CreatorProperty[] constructorArgs) Method for setting properties related to instantiating values from JSON Object.voidcreateFromBoolean(boolean value) createFromDouble(double value) createFromInt(int value) createFromLong(long value) createFromObjectWith(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(String value) 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.createUsingDelegate(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 "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".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 (whenValueInstantiator.canCreateFromObjectWith()returns true).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).protected JsonMappingExceptionMethods inherited from class org.codehaus.jackson.map.deser.ValueInstantiator
canCreateUsingDelegate, canInstantiate
-
Field Details
-
_valueTypeDesc
Type of values that are instantiated; used for error reporting purposes. -
_cfgEmptyStringsAsObjects
protected final boolean _cfgEmptyStringsAsObjectsAre we allowed to convert empty Strings to null objects? -
_defaultCreator
Default (no-argument) constructor to use for instantiation (withcreateUsingDefault()) -
_constructorArguments
-
_withArgsCreator
-
_delegateType
-
_delegateCreator
-
_fromStringCreator
-
_fromIntCreator
-
_fromLongCreator
-
_fromDoubleCreator
-
_fromBooleanCreator
-
-
Constructor Details
-
StdValueInstantiator
-
StdValueInstantiator
-
StdValueInstantiator
Copy-constructor that sub-classes can use when creating new instances by fluent-style construction
-
-
Method Details
-
configureFromObjectSettings
public void configureFromObjectSettings(AnnotatedWithParams defaultCreator, AnnotatedWithParams delegateCreator, JavaType delegateType, AnnotatedWithParams withArgsCreator, CreatorProperty[] 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 -
configureFromStringCreator
-
configureFromIntCreator
-
configureFromLongCreator
-
configureFromDoubleCreator
-
configureFromBooleanCreator
-
getValueTypeDesc
Description copied from class:ValueInstantiatorMethod that returns description of the value type this instantiator handles. Used for error messages, diagnostics.- Specified by:
getValueTypeDescin 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(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(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(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(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
-
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
-
getDelegateType
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
-
getFromObjectArguments
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
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()returns null or empty List.- Overrides:
createUsingDefaultin classValueInstantiator- Throws:
IOExceptionJsonProcessingException
-
createFromObjectWith
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()returns a non-empty List of arguments.- Overrides:
createFromObjectWithin classValueInstantiator- Throws:
IOExceptionJsonProcessingException
-
createUsingDelegate
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:
IOExceptionJsonProcessingException
-
createFromString
- Overrides:
createFromStringin classValueInstantiator- Throws:
IOExceptionJsonProcessingException
-
createFromInt
- Overrides:
createFromIntin classValueInstantiator- Throws:
IOExceptionJsonProcessingException
-
createFromLong
- Overrides:
createFromLongin classValueInstantiator- Throws:
IOExceptionJsonProcessingException
-
createFromDouble
- Overrides:
createFromDoublein classValueInstantiator- Throws:
IOExceptionJsonProcessingException
-
createFromBoolean
- Overrides:
createFromBooleanin classValueInstantiator- Throws:
IOExceptionJsonProcessingException
-
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
-
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
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
-
_createFromStringFallbacks
protected Object _createFromStringFallbacks(String value) throws IOException, JsonProcessingException - Throws:
IOExceptionJsonProcessingException
-
wrapException
-