Class CreatorProperty
- java.lang.Object
-
- com.fasterxml.jackson.databind.introspect.ConcreteBeanPropertyBase
-
- com.fasterxml.jackson.databind.deser.SettableBeanProperty
-
- com.fasterxml.jackson.databind.deser.CreatorProperty
-
- All Implemented Interfaces:
BeanProperty,Named,Serializable
public class CreatorProperty extends SettableBeanProperty
This concrete sub-class implements property that is passed via Creator (constructor or static factory method). It is not a full-featured implementation in that its set method should usually not be called for primary mutation -- instead, value must separately passed -- but some aspects are still needed (specifically, injection).Note on injectable values: unlike with other mutators, where deserializer and injecting are separate, here we treat the two as related things. This is necessary to add proper priority, as well as to simplify coordination.
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.fasterxml.jackson.databind.deser.SettableBeanProperty
SettableBeanProperty.Delegating
-
Nested classes/interfaces inherited from interface com.fasterxml.jackson.databind.BeanProperty
BeanProperty.Bogus, BeanProperty.Std
-
-
Field Summary
Fields Modifier and Type Field Description protected AnnotatedParameter_annotatedPlaceholder that represents constructor parameter, when it is created from actual constructor.protected int_creatorIndexprotected SettableBeanProperty_fallbackSetterIn special cases, when implementing "updateValue", we cannot use constructors or factory methods, but have to fall back on using a setter (or mutable field property).protected boolean_ignorableMarker flag that may have to be set during construction, to indicate that although property may have been constructed and added as a placeholder, it represents something that should be ignored during deserialization.protected Object_injectableValueIdId of value to inject, if value injection should be used for this parameter (in addition to, or instead of, regular deserialization).-
Fields inherited from class com.fasterxml.jackson.databind.deser.SettableBeanProperty
_contextAnnotations, _managedReferenceName, _nullProvider, _objectIdInfo, _propertyIndex, _propName, _type, _valueDeserializer, _valueTypeDeserializer, _viewMatcher, _wrapperName, MISSING_VALUE_DESERIALIZER
-
Fields inherited from class com.fasterxml.jackson.databind.introspect.ConcreteBeanPropertyBase
_aliases, _metadata
-
Fields inherited from interface com.fasterxml.jackson.databind.BeanProperty
EMPTY_FORMAT, EMPTY_INCLUDE
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedCreatorProperty(CreatorProperty src, JsonDeserializer<?> deser, NullValueProvider nva)protectedCreatorProperty(CreatorProperty src, PropertyName newName)CreatorProperty(PropertyName name, JavaType type, PropertyName wrapperName, TypeDeserializer typeDeser, Annotations contextAnnotations, AnnotatedParameter param, int index, Object injectableValueId, PropertyMetadata metadata)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddeserializeAndSet(com.fasterxml.jackson.core.JsonParser p, DeserializationContext ctxt, Object instance)Method called to deserialize appropriate value, given parser (and context), and set it using appropriate mechanism.ObjectdeserializeSetAndReturn(com.fasterxml.jackson.core.JsonParser p, DeserializationContext ctxt, Object instance)Alternative toSettableBeanProperty.deserializeAndSet(com.fasterxml.jackson.core.JsonParser, com.fasterxml.jackson.databind.DeserializationContext, java.lang.Object)that returns either return value of setter method called (if one is), or null to indicate that no return value is available.ObjectfindInjectableValue(DeserializationContext context, Object beanInstance)Method that can be called to locate value to be injected for this property, if it is configured for this.voidfixAccess(DeserializationConfig config)Method called to ensure that the mutator has proper access rights to be called, as per configuration.<A extends Annotation>
AgetAnnotation(Class<A> acls)Method for finding annotation associated with this property; meaning annotation associated with one of entities used to access property.intgetCreatorIndex()Method for accessing index of the creator property: for other types of properties will simply return -1.ObjectgetInjectableValueId()Accessor for id of injectable value, if this bean property supports value injection.AnnotatedMembergetMember()Method for accessing primary physical entity that represents the property; annotated field, method or constructor property.PropertyMetadatagetMetadata()Accessor for additional optional information about property.voidinject(DeserializationContext context, Object beanInstance)Method to find value to inject, and inject it to this property.booleanisIgnorable()voidmarkAsIgnorable()voidset(Object instance, Object value)Method called to assign given value to this property, on specified Object.ObjectsetAndReturn(Object instance, Object value)Method called to assign given value to this property, on specified Object, and return whatever delegating accessor returned (if anything)voidsetFallbackSetter(SettableBeanProperty fallbackSetter)NOTE: one exception to immutability, due to problems with CreatorProperty instances being shared between Bean, separate PropertyBasedCreatorStringtoString()SettableBeanPropertywithName(PropertyName newName)Fluent factory method for constructing and returning a new instance with specified property name.SettableBeanPropertywithNullProvider(NullValueProvider nva)SettableBeanPropertywithValueDeserializer(JsonDeserializer<?> deser)Fluent factory method for constructing and returning a new instance with specified value deserializer.-
Methods inherited from class com.fasterxml.jackson.databind.deser.SettableBeanProperty
_throwAsIOE, _throwAsIOE, _throwAsIOE, _throwAsIOE, assignIndex, depositSchemaProperty, deserialize, deserializeWith, getContextAnnotation, getDeclaringClass, getFullName, getManagedReferenceName, getName, getNullValueProvider, getObjectIdInfo, getPropertyIndex, getType, getValueDeserializer, getValueTypeDeserializer, getWrapperName, hasValueDeserializer, hasValueTypeDeserializer, hasViews, setManagedReferenceName, setObjectIdInfo, setViews, visibleInView, withSimpleName
-
Methods inherited from class com.fasterxml.jackson.databind.introspect.ConcreteBeanPropertyBase
findAliases, findFormatOverrides, findPropertyFormat, findPropertyInclusion, isRequired, isVirtual
-
-
-
-
Field Detail
-
_annotated
protected final AnnotatedParameter _annotated
Placeholder that represents constructor parameter, when it is created from actual constructor. May be null when a synthetic instance is created.
-
_injectableValueId
protected final Object _injectableValueId
Id of value to inject, if value injection should be used for this parameter (in addition to, or instead of, regular deserialization).
-
_fallbackSetter
protected SettableBeanProperty _fallbackSetter
In special cases, when implementing "updateValue", we cannot use constructors or factory methods, but have to fall back on using a setter (or mutable field property). If so, this refers to that fallback accessor.Mutable only to allow setting after construction, but must be strictly set before any use.
- Since:
- 2.3
-
_creatorIndex
protected final int _creatorIndex
- Since:
- 2.1
-
_ignorable
protected boolean _ignorable
Marker flag that may have to be set during construction, to indicate that although property may have been constructed and added as a placeholder, it represents something that should be ignored during deserialization. This mostly concerns Creator properties which may not be easily deleted during processing.- Since:
- 2.9.4
-
-
Constructor Detail
-
CreatorProperty
public CreatorProperty(PropertyName name, JavaType type, PropertyName wrapperName, TypeDeserializer typeDeser, Annotations contextAnnotations, AnnotatedParameter param, int index, Object injectableValueId, PropertyMetadata metadata)
- Parameters:
name- Name of the logical propertytype- Type of the property, used to find deserializertypeDeser- Type deserializer to use for handling polymorphic type information, if one is neededcontextAnnotations- Contextual annotations (usually by class that declares creator [constructor, factory method] that includes this property)param- Representation of property, constructor or factory method parameter; used for accessing annotations of the propertyindex- Index of this property within creator invocation- Since:
- 2.3
-
CreatorProperty
protected CreatorProperty(CreatorProperty src, PropertyName newName)
- Since:
- 2.3
-
CreatorProperty
protected CreatorProperty(CreatorProperty src, JsonDeserializer<?> deser, NullValueProvider nva)
-
-
Method Detail
-
withName
public SettableBeanProperty withName(PropertyName newName)
Description copied from class:SettableBeanPropertyFluent factory method for constructing and returning a new instance with specified property name. Note that this method should NOT change configuration of this instance.- Specified by:
withNamein classSettableBeanProperty- Parameters:
newName- Name to use for the new instance.- Returns:
- Newly constructed instance, if property name differs from the one used for this instance; or 'this' if not.
-
withValueDeserializer
public SettableBeanProperty withValueDeserializer(JsonDeserializer<?> deser)
Description copied from class:SettableBeanPropertyFluent factory method for constructing and returning a new instance with specified value deserializer. Note that this method should NOT change configuration of this instance.- Specified by:
withValueDeserializerin classSettableBeanProperty- Parameters:
deser- Deserializer to assign to the new property instance- Returns:
- Newly constructed instance, if value deserializer differs from the one used for this instance; or 'this' if not.
-
withNullProvider
public SettableBeanProperty withNullProvider(NullValueProvider nva)
- Specified by:
withNullProviderin classSettableBeanProperty
-
fixAccess
public void fixAccess(DeserializationConfig config)
Description copied from class:SettableBeanPropertyMethod called to ensure that the mutator has proper access rights to be called, as per configuration. Overridden by implementations that have mutators that require access, fields and setters.- Overrides:
fixAccessin classSettableBeanProperty
-
setFallbackSetter
public void setFallbackSetter(SettableBeanProperty fallbackSetter)
NOTE: one exception to immutability, due to problems with CreatorProperty instances being shared between Bean, separate PropertyBasedCreator- Since:
- 2.6
-
markAsIgnorable
public void markAsIgnorable()
- Overrides:
markAsIgnorablein classSettableBeanProperty
-
isIgnorable
public boolean isIgnorable()
- Overrides:
isIgnorablein classSettableBeanProperty
-
findInjectableValue
public Object findInjectableValue(DeserializationContext context, Object beanInstance) throws JsonMappingException
Method that can be called to locate value to be injected for this property, if it is configured for this.- Throws:
JsonMappingException
-
inject
public void inject(DeserializationContext context, Object beanInstance) throws IOException
Method to find value to inject, and inject it to this property.- Throws:
IOException
-
getAnnotation
public <A extends Annotation> A getAnnotation(Class<A> acls)
Description copied from interface:BeanPropertyMethod for finding annotation associated with this property; meaning annotation associated with one of entities used to access property.Note that this method should only be called for custom annotations; access to standard Jackson annotations (or ones supported by alternate
AnnotationIntrospectors) should be accessed throughAnnotationIntrospector.- Specified by:
getAnnotationin interfaceBeanProperty- Specified by:
getAnnotationin classSettableBeanProperty
-
getMember
public AnnotatedMember getMember()
Description copied from interface:BeanPropertyMethod for accessing primary physical entity that represents the property; annotated field, method or constructor property.- Specified by:
getMemberin interfaceBeanProperty- Specified by:
getMemberin classSettableBeanProperty
-
getCreatorIndex
public int getCreatorIndex()
Description copied from class:SettableBeanPropertyMethod for accessing index of the creator property: for other types of properties will simply return -1.- Overrides:
getCreatorIndexin classSettableBeanProperty
-
deserializeAndSet
public void deserializeAndSet(com.fasterxml.jackson.core.JsonParser p, DeserializationContext ctxt, Object instance) throws IOExceptionDescription copied from class:SettableBeanPropertyMethod called to deserialize appropriate value, given parser (and context), and set it using appropriate mechanism. Pre-condition is that passed parser must point to the first token that should be consumed to produce the value (the only value for scalars, multiple for Objects and Arrays).- Specified by:
deserializeAndSetin classSettableBeanProperty- Throws:
IOException
-
deserializeSetAndReturn
public Object deserializeSetAndReturn(com.fasterxml.jackson.core.JsonParser p, DeserializationContext ctxt, Object instance) throws IOException
Description copied from class:SettableBeanPropertyAlternative toSettableBeanProperty.deserializeAndSet(com.fasterxml.jackson.core.JsonParser, com.fasterxml.jackson.databind.DeserializationContext, java.lang.Object)that returns either return value of setter method called (if one is), or null to indicate that no return value is available. Mostly used to support Builder style deserialization.- Specified by:
deserializeSetAndReturnin classSettableBeanProperty- Throws:
IOException
-
set
public void set(Object instance, Object value) throws IOException
Description copied from class:SettableBeanPropertyMethod called to assign given value to this property, on specified Object.Note: this is an optional operation, not supported by all implementations, creator-backed properties for example do not support this method.
- Specified by:
setin classSettableBeanProperty- Throws:
IOException
-
setAndReturn
public Object setAndReturn(Object instance, Object value) throws IOException
Description copied from class:SettableBeanPropertyMethod called to assign given value to this property, on specified Object, and return whatever delegating accessor returned (if anything)Note: this is an optional operation, not supported by all implementations, creator-backed properties for example do not support this method.
- Specified by:
setAndReturnin classSettableBeanProperty- Throws:
IOException
-
getMetadata
public PropertyMetadata getMetadata()
Description copied from interface:BeanPropertyAccessor for additional optional information about property.- Specified by:
getMetadatain interfaceBeanProperty- Overrides:
getMetadatain classConcreteBeanPropertyBase- Returns:
- Metadata about property; never null.
-
getInjectableValueId
public Object getInjectableValueId()
Description copied from class:SettableBeanPropertyAccessor for id of injectable value, if this bean property supports value injection.- Overrides:
getInjectableValueIdin classSettableBeanProperty
-
toString
public String toString()
- Overrides:
toStringin classSettableBeanProperty
-
-