Top Description Inners Fields Constructors Methods
tools.jackson.databind.ser

public Class BeanPropertyWriter

extends PropertyWriter
Class Inheritance
Known Direct Subclasses
tools.jackson.databind.ser.VirtualBeanPropertyWriter, tools.jackson.databind.ser.bean.UnwrappingBeanPropertyWriter, tools.jackson.databind.ser.impl.FilteredBeanPropertyWriter.SingleView, tools.jackson.databind.ser.impl.FilteredBeanPropertyWriter.MultiView, tools.jackson.databind.ser.AnyGetterWriter
Annotations
@JacksonStdImpl
Imports
java.lang.annotation.Annotation, java.lang.invoke.MethodHandle, .MethodHandles, java.lang.reflect.Field, .Method, java.util.HashMap, com.fasterxml.jackson.annotation.JsonInclude, tools.jackson.core.JacksonException, .JsonGenerator, .SerializableString, tools.jackson.core.io.SerializedString, tools.jackson.databind.*, tools.jackson.databind.annotation.JacksonStdImpl, tools.jackson.databind.introspect.*, tools.jackson.databind.jsonFormatVisitors.JsonObjectFormatVisitor, tools.jackson.databind.jsontype.TypeSerializer, tools.jackson.databind.node.ObjectNode, tools.jackson.databind.ser.bean.BeanSerializerBase, .UnwrappingBeanPropertyWriter, tools.jackson.databind.ser.impl.PropertySerializerMap, tools.jackson.databind.util.Annotations, .ClassUtil, .NameTransformer, tools.jackson.databind.util.internal.UnreflectHandleSupplier

Base bean property handler class, which implements common parts of reflection-based functionality for accessing a property value and serializing it.

Note that current design tries to keep instances immutable (semi-functional style); mostly because these instances are exposed to application code and this is to reduce likelihood of data corruption and synchronization issues.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv class

Field Summary

Modifier and TypeField and Description
protected final BeanPropertyWriter.GetterHolder
_accessor

Accessor method used to get property value.

protected final JavaType
_cfgSerializationType

Type to use for locating serializer; normally same as return type of the accessor method, but may be overridden by annotations.

protected final transient Annotations
_contextAnnotations

Annotations from context (most often, class that declares property, or in case of sub-class serializer, from that sub-class)

Note

transient just to support JDK serializability; Annotations do not serialize.

protected final JavaType
_declaredType

Type property is declared to have, either in class definition or associated annotations.

protected transient PropertySerializerMap
_dynamicSerializers

In case serializer is not known statically (i.e. _serializer is null), we will use a lookup structure for storing dynamically resolved mapping from type(s) to serializer(s).

protected final Class<?>[]
_includeInViews

Alternate set of property writers used when view-based filtering is available for the Bean.

protected transient HashMap<Object, Object>
protected final AnnotatedMember
_member

Member (field, method) that represents property and allows access to associated annotations.

protected final SerializedString
_name

Logical name of the property; will be used as the field name under which value for the property is written.

protected JavaType
_nonTrivialBaseType

Base type of the property, if the declared type is "non-trivial"; meaning it is either a structured type (collection, map, array), or parameterized.

protected ValueSerializer<Object>
_nullSerializer

Serializer used for writing out null values, if any: if null, null values are to be suppressed.

protected ValueSerializer<Object>
_serializer

Serializer to use for writing out the value: null if it cannot be known statically; non-null if it can.

protected final Object
_suppressableValue

Value that is considered default value of the property; used for default-value-suppression if enabled.

protected final boolean
_suppressNulls

Whether null values are to be suppressed (nothing written out if value is null) or not.

protected TypeSerializer
_typeSerializer

If property being serialized needs type information to be included this is the type serializer to use.

protected final PropertyName
_wrapperName

Wrapper name to use for this element, if any

public static final Object
MARKER_FOR_EMPTY

Marker object used to indicate "do not serialize if empty"

Constructor Summary

AccessConstructor and Description
public
BeanPropertyWriter(BeanPropertyDefinition propDef, AnnotatedMember member, Annotations contextAnnotations, JavaType declaredType, ValueSerializer<?> ser, TypeSerializer typeSer, JavaType serType, boolean suppressNulls, Object suppressableValue, Class<?>[] includeInViews)

protected
BeanPropertyWriter()

Constructor that may be of use to virtual properties, when there is need for the zero-arg ("default") constructor, and actual initialization is done after constructor call.

protected
BeanPropertyWriter(BeanPropertyWriter base)

"Copy constructor" to be used by filtering sub-classes

protected
protected

Method Summary

Modifier and TypeMethod and Description
protected void
_depositSchemaProperty(ObjectNode propertiesNode, JsonNode schemaNode)

protected ValueSerializer<Object>
protected boolean

Returns:

True if method fully handled self-referential value; false if not (caller is to handle it) or DatabindException if there is no way handle it
_handleSelfReference
(Object bean, JsonGenerator g, SerializationContext ctxt, ValueSerializer<?> ser)

Method called to handle a direct self-reference through this property.

private boolean
protected BeanPropertyWriter
_new(PropertyName newName)

Overridable factory method used by sub-classes

public void
assignNullSerializer(ValueSerializer<Object> nullSer)

Method called to assign null value serializer for property

public void
assignSerializer(ValueSerializer<Object> ser)

Method called to assign value serializer for property

public void
assignTypeSerializer(TypeSerializer typeSer)

Method called to set, reset or clear the configured type serializer for property.

public void
depositSchemaProperty(JsonObjectFormatVisitor v, SerializationContext provider)

Implements abstract tools.jackson.databind.ser.PropertyWriter.depositSchemaProperty.

Implements tools.jackson.databind.BeanProperty.depositSchemaProperty.

Traversal method used for things like JSON Schema generation, or POJO introspection.

public void
fixAccess(SerializationConfig config)

Method called to ensure that the mutator has proper access rights to be called, as per configuration.

public final Object
get(Object bean)

Method that can be used to access value of the property this Object describes, from given bean instance.

public <A extends Annotation> A
getAnnotation(Class<A> acls)

Implements abstract tools.jackson.databind.ser.PropertyWriter.getAnnotation.

Implements tools.jackson.databind.BeanProperty.getAnnotation.

Method for accessing annotations directly declared for property that this writer is associated with.

public <A extends Annotation> A
getContextAnnotation(Class<A> acls)

Implements abstract tools.jackson.databind.ser.PropertyWriter.getContextAnnotation.

Implements tools.jackson.databind.BeanProperty.getContextAnnotation.

Method for accessing annotations declared in context of the property that this writer is associated with; usually this means annotations on enclosing class for property.

public PropertyName
public Object

Returns:

Value of the setting, if any; null if none.
getInternalSetting
(Object key)

Method for accessing value of specified internal setting.

public AnnotatedMember
getMember()

Implements tools.jackson.databind.BeanProperty.getMember.

Method for accessing primary physical entity that represents the property; annotated field, method or constructor property.

public String
public JavaType
public SerializableString
public ValueSerializer<Object>
public JavaType
getType()

Implements tools.jackson.databind.BeanProperty.getType.

Method to get declared type of the property.

public TypeSerializer
public Class<?>[]
public PropertyName
getWrapperName()

Implements tools.jackson.databind.BeanProperty.getWrapperName.

If property is indicated to be wrapped, name of wrapper element to use.

public boolean
public boolean
public boolean
isUnwrapping()

Accessor that will return true if this bean property has to support "unwrapping"; ability to replace POJO structural wrapping with optional name prefix and/or suffix (or in some cases, just removal of wrapper name).

public Object

Returns:

Existing value of the setting, if any (null if none)
removeInternalSetting
(Object key)

Method for removing entry for specified internal setting.

public BeanPropertyWriter
rename(NameTransformer transformer)

public void
serializeAsElement(Object bean, JsonGenerator g, SerializationContext ctxt)

Implements abstract tools.jackson.databind.ser.PropertyWriter.serializeAsElement.

Alternative to serializeAsProperty that is used when a POJO is serialized as JSON Array (usually when "Shape" is forced as 'Array'): the difference is that no property names are written.

public void
serializeAsOmittedElement(Object bean, JsonGenerator g, SerializationContext prov)

Implements abstract tools.jackson.databind.ser.PropertyWriter.serializeAsOmittedElement.

Method called to serialize a placeholder used in tabular output when real value is not to be included (is filtered out), but when we need an entry so that field indexes will not be off.

public void
serializeAsOmittedProperty(Object bean, JsonGenerator g, SerializationContext ctxt)

Implements abstract tools.jackson.databind.ser.PropertyWriter.serializeAsOmittedProperty.

Method called to indicate that serialization of a field was omitted due to filtering, in cases where backend data format does not allow basic omission.

public void
serializeAsProperty(Object bean, JsonGenerator g, SerializationContext ctxt)

Implements abstract tools.jackson.databind.ser.PropertyWriter.serializeAsProperty.

Method called to access property that this bean stands for, from within given bean, and to serialize it as a JSON Object field using appropriate serializer.

public Object

Returns:

Old value of the setting, if any (null if none)
setInternalSetting
(Object key, Object value)

Method for setting specific internal setting to given value

public void
setNonTrivialBaseType(JavaType t)

Method called to define type to consider as "non-trivial" basetype, needed for dynamic serialization resolution for complex (usually container) types

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public BeanPropertyWriter
unwrappingWriter(NameTransformer unwrapper)

Method called create an instance that handles details of unwrapping contained value.

public boolean
public boolean
wouldConflictWithName(PropertyName name)

Method called to check to see if this property has a name that would conflict with a given name.

Inherited from tools.jackson.databind.ser.PropertyWriter:
findAnnotation

Field Detail

_accessorback to summary
protected final BeanPropertyWriter.GetterHolder _accessor

Accessor method used to get property value. Wrapped in a holder since MethodHandle is not serializable.

_cfgSerializationTypeback to summary
protected final JavaType _cfgSerializationType

Type to use for locating serializer; normally same as return type of the accessor method, but may be overridden by annotations.

_contextAnnotationsback to summary
protected final transient Annotations _contextAnnotations

Annotations from context (most often, class that declares property, or in case of sub-class serializer, from that sub-class)

Note

transient just to support JDK serializability; Annotations do not serialize. At all.

_declaredTypeback to summary
protected final JavaType _declaredType

Type property is declared to have, either in class definition or associated annotations.

_dynamicSerializersback to summary
protected transient PropertySerializerMap _dynamicSerializers

In case serializer is not known statically (i.e. _serializer is null), we will use a lookup structure for storing dynamically resolved mapping from type(s) to serializer(s).

_includeInViewsback to summary
protected final Class<?>[] _includeInViews

Alternate set of property writers used when view-based filtering is available for the Bean.

_internalSettingsback to summary
protected transient HashMap<Object, Object> _internalSettings
_memberback to summary
protected final AnnotatedMember _member

Member (field, method) that represents property and allows access to associated annotations.

_nameback to summary
protected final SerializedString _name

Logical name of the property; will be used as the field name under which value for the property is written.

Note

do NOT change name of this field; it is accessed by Afterburner module (until 2.4; not directly from 2.5) ALSO NOTE: ... and while it really ought to be `SerializableString`, changing that is also binary-incompatible change. So nope.

_nonTrivialBaseTypeback to summary
protected JavaType _nonTrivialBaseType

Base type of the property, if the declared type is "non-trivial"; meaning it is either a structured type (collection, map, array), or parameterized. Used to retain type information about contained type, which is mostly necessary if type meta-data is to be included.

_nullSerializerback to summary
protected ValueSerializer<Object> _nullSerializer

Serializer used for writing out null values, if any: if null, null values are to be suppressed.

_serializerback to summary
protected ValueSerializer<Object> _serializer

Serializer to use for writing out the value: null if it cannot be known statically; non-null if it can.

_suppressableValueback to summary
protected final Object _suppressableValue

Value that is considered default value of the property; used for default-value-suppression if enabled.

_suppressNullsback to summary
protected final boolean _suppressNulls

Whether null values are to be suppressed (nothing written out if value is null) or not. Note that this is a configuration value during construction, and actual handling relies on setting (or not) of _nullSerializer.

_typeSerializerback to summary
protected TypeSerializer _typeSerializer

If property being serialized needs type information to be included this is the type serializer to use. Declared type (possibly augmented with annotations) of property is used for determining exact mechanism to use (compared to actual runtime type used for serializing actual state).

_wrapperNameback to summary
protected final PropertyName _wrapperName

Wrapper name to use for this element, if any

MARKER_FOR_EMPTYback to summary
public static final Object MARKER_FOR_EMPTY

Marker object used to indicate "do not serialize if empty"

Constructor Detail

BeanPropertyWriterback to summary
public BeanPropertyWriter(BeanPropertyDefinition propDef, AnnotatedMember member, Annotations contextAnnotations, JavaType declaredType, ValueSerializer<?> ser, TypeSerializer typeSer, JavaType serType, boolean suppressNulls, Object suppressableValue, Class<?>[] includeInViews)
Annotations
@SuppressWarnings:unchecked
BeanPropertyWriterback to summary
protected BeanPropertyWriter()

Constructor that may be of use to virtual properties, when there is need for the zero-arg ("default") constructor, and actual initialization is done after constructor call.

BeanPropertyWriterback to summary
protected BeanPropertyWriter(BeanPropertyWriter base)

"Copy constructor" to be used by filtering sub-classes

BeanPropertyWriterback to summary
protected BeanPropertyWriter(BeanPropertyWriter base, PropertyName name)
BeanPropertyWriterback to summary
protected BeanPropertyWriter(BeanPropertyWriter base, SerializedString name)

Method Detail

_depositSchemaPropertyback to summary
protected void _depositSchemaProperty(ObjectNode propertiesNode, JsonNode schemaNode)
_findAndAddDynamicback to summary
protected ValueSerializer<Object> _findAndAddDynamic(PropertySerializerMap map, Class<?> rawType, SerializationContext provider)
_handleSelfReferenceback to summary
protected boolean _handleSelfReference(Object bean, JsonGenerator g, SerializationContext ctxt, ValueSerializer<?> ser) throws JacksonException

Method called to handle a direct self-reference through this property. Method can choose to indicate an error by throwing DatabindException; fully handle serialization (and return true); or indicate that it should be serialized normally (return false).

Default implementation will throw DatabindException if SerializationFeature#FAIL_ON_SELF_REFERENCES is enabled; or return false if it is disabled.

Returns:boolean

True if method fully handled self-referential value; false if not (caller is to handle it) or DatabindException if there is no way handle it

_isThrowableFieldCauseback to summary
private boolean _isThrowableFieldCause(SerializationContext ctxt, Object bean)
_newback to summary
protected BeanPropertyWriter _new(PropertyName newName)

Overridable factory method used by sub-classes

assignNullSerializerback to summary
public void assignNullSerializer(ValueSerializer<Object> nullSer)

Method called to assign null value serializer for property

assignSerializerback to summary
public void assignSerializer(ValueSerializer<Object> ser)

Method called to assign value serializer for property

assignTypeSerializerback to summary
public void assignTypeSerializer(TypeSerializer typeSer)

Method called to set, reset or clear the configured type serializer for property.

depositSchemaPropertyback to summary
public void depositSchemaProperty(JsonObjectFormatVisitor v, SerializationContext provider)

Implements abstract tools.jackson.databind.ser.PropertyWriter.depositSchemaProperty.

Implements tools.jackson.databind.BeanProperty.depositSchemaProperty.

Doc from tools.jackson.databind.ser.PropertyWriter.depositSchemaProperty.

Traversal method used for things like JSON Schema generation, or POJO introspection.

Annotations
@Override
fixAccessback to summary
public void fixAccess(SerializationConfig config)

Method 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.

getback to summary
public final Object get(Object bean) throws Exception

Method that can be used to access value of the property this Object describes, from given bean instance.

getAnnotationback to summary
public <A extends Annotation> A getAnnotation(Class<A> acls)

Implements abstract tools.jackson.databind.ser.PropertyWriter.getAnnotation.

Implements tools.jackson.databind.BeanProperty.getAnnotation.

Doc from tools.jackson.databind.ser.PropertyWriter.getAnnotation.

Method for accessing annotations directly declared for property that this writer is associated with.

Annotations
@Override
getContextAnnotationback to summary
public <A extends Annotation> A getContextAnnotation(Class<A> acls)

Implements abstract tools.jackson.databind.ser.PropertyWriter.getContextAnnotation.

Implements tools.jackson.databind.BeanProperty.getContextAnnotation.

Doc from tools.jackson.databind.ser.PropertyWriter.getContextAnnotation.

Method for accessing annotations declared in context of the property that this writer is associated with; usually this means annotations on enclosing class for property.

Annotations
@Override
getFullNameback to summary
public PropertyName getFullName()

Implements abstract tools.jackson.databind.ser.PropertyWriter.getFullName.

Implements tools.jackson.databind.util.FullyNamed.getFullName.

Annotations
@Override
getInternalSettingback to summary
public Object getInternalSetting(Object key)

Method for accessing value of specified internal setting.

Returns:Object

Value of the setting, if any; null if none.

getMemberback to summary
public AnnotatedMember getMember()

Implements tools.jackson.databind.BeanProperty.getMember.

Doc from tools.jackson.databind.BeanProperty.getMember.

Method for accessing primary physical entity that represents the property; annotated field, method or constructor property.

Annotations
@Override
getNameback to summary
public String getName()

Implements abstract tools.jackson.databind.ser.PropertyWriter.getName.

Implements tools.jackson.core.util.Named.getName.

Annotations
@Override
getSerializationTypeback to summary
public JavaType getSerializationType()
getSerializedNameback to summary
public SerializableString getSerializedName()
getSerializerback to summary
public ValueSerializer<Object> getSerializer()
getTypeback to summary
public JavaType getType()

Implements tools.jackson.databind.BeanProperty.getType.

Doc from tools.jackson.databind.BeanProperty.getType.

Method to get declared type of the property.

Annotations
@Override
getTypeSerializerback to summary
public TypeSerializer getTypeSerializer()
getViewsback to summary
public Class<?>[] getViews()
getWrapperNameback to summary
public PropertyName getWrapperName()

Implements tools.jackson.databind.BeanProperty.getWrapperName.

Doc from tools.jackson.databind.BeanProperty.getWrapperName.

If property is indicated to be wrapped, name of wrapper element to use.

Annotations
@Override
hasNullSerializerback to summary
public boolean hasNullSerializer()
hasSerializerback to summary
public boolean hasSerializer()
isUnwrappingback to summary
public boolean isUnwrapping()

Accessor that will return true if this bean property has to support "unwrapping"; ability to replace POJO structural wrapping with optional name prefix and/or suffix (or in some cases, just removal of wrapper name).

Default implementation simply returns false.

removeInternalSettingback to summary
public Object removeInternalSetting(Object key)

Method for removing entry for specified internal setting.

Returns:Object

Existing value of the setting, if any (null if none)

renameback to summary
public BeanPropertyWriter rename(NameTransformer transformer)
serializeAsElementback to summary
public void serializeAsElement(Object bean, JsonGenerator g, SerializationContext ctxt) throws Exception

Implements abstract tools.jackson.databind.ser.PropertyWriter.serializeAsElement.

Alternative to serializeAsProperty that is used when a POJO is serialized as JSON Array (usually when "Shape" is forced as 'Array'): the difference is that no property names are written.

Annotations
@Override
serializeAsOmittedElementback to summary
public void serializeAsOmittedElement(Object bean, JsonGenerator g, SerializationContext prov) throws Exception

Implements abstract tools.jackson.databind.ser.PropertyWriter.serializeAsOmittedElement.

Method called to serialize a placeholder used in tabular output when real value is not to be included (is filtered out), but when we need an entry so that field indexes will not be off. Typically this should output null or empty String, depending on datatype.

Annotations
@Override
serializeAsOmittedPropertyback to summary
public void serializeAsOmittedProperty(Object bean, JsonGenerator g, SerializationContext ctxt) throws Exception

Implements abstract tools.jackson.databind.ser.PropertyWriter.serializeAsOmittedProperty.

Method called to indicate that serialization of a field was omitted due to filtering, in cases where backend data format does not allow basic omission.

Annotations
@Override
serializeAsPropertyback to summary
public void serializeAsProperty(Object bean, JsonGenerator g, SerializationContext ctxt) throws Exception

Implements abstract tools.jackson.databind.ser.PropertyWriter.serializeAsProperty.

Method called to access property that this bean stands for, from within given bean, and to serialize it as a JSON Object field using appropriate serializer.

Annotations
@Override
setInternalSettingback to summary
public Object setInternalSetting(Object key, Object value)

Method for setting specific internal setting to given value

Returns:Object

Old value of the setting, if any (null if none)

setNonTrivialBaseTypeback to summary
public void setNonTrivialBaseType(JavaType t)

Method called to define type to consider as "non-trivial" basetype, needed for dynamic serialization resolution for complex (usually container) types

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Annotations
@Override
unwrappingWriterback to summary
public BeanPropertyWriter unwrappingWriter(NameTransformer unwrapper)

Method called create an instance that handles details of unwrapping contained value.

willSuppressNullsback to summary
public boolean willSuppressNulls()
wouldConflictWithNameback to summary
public boolean wouldConflictWithName(PropertyName name)

Method called to check to see if this property has a name that would conflict with a given name.

Since
2.6
tools.jackson.databind.ser back to summary

pack-priv Class BeanPropertyWriter.GetterHolder

extends UnreflectHandleSupplier
Class Inheritance

Field Summary

Modifier and TypeField and Description
private static final long

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected MethodHandle
Inherited from tools.jackson.databind.util.internal.UnreflectHandleSupplier:
getpostprocesstoString

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

Constructor Detail

GetterHolderback to summary
public GetterHolder()

Method Detail

unreflectback to summary
protected MethodHandle unreflect() throws IllegalAccessException

Implements abstract tools.jackson.databind.util.internal.UnreflectHandleSupplier.unreflect.

Annotations
@Override