- All Implemented Interfaces:
Named,BeanProperty,FullyNamed
- Direct Known Subclasses:
AnyGetterWriter,UnwrappingBeanPropertyWriter,VirtualBeanPropertyWriter
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 Class Summary
Nested classes/interfaces inherited from interface tools.jackson.databind.BeanProperty
BeanProperty.Bogus, BeanProperty.StdNested classes/interfaces inherited from interface tools.jackson.core.util.Named
Named.StringAsNamed -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final tools.jackson.databind.ser.BeanPropertyWriter.GetterHolderAccessor method used to get property value.protected final JavaTypeType to use for locating serializer; normally same as return type of the accessor method, but may be overridden by annotations.protected final AnnotationsAnnotations from context (most often, class that declares property, or in case of sub-class serializer, from that sub-class)protected final JavaTypeType property is declared to have, either in class definition or associated annotations.protected PropertySerializerMapIn case serializer is not known statically (i.e.protected final Class<?>[]Alternate set of property writers used when view-based filtering is available for the Bean.protected final AnnotatedMemberMember (field, method) that represents property and allows access to associated annotations.protected final SerializedStringLogical name of the property; will be used as the field name under which value for the property is written.protected JavaTypeBase 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>Serializer used for writing out null values, if any: if null, null values are to be suppressed.protected ValueSerializer<Object>Serializer to use for writing out the value: null if it cannot be known statically; non-null if it can.protected final ObjectValue that is considered default value of the property; used for default-value-suppression if enabled.protected final booleanWhether null values are to be suppressed (nothing written out if value is null) or not.protected TypeSerializerIf property being serialized needs type information to be included this is the type serializer to use.protected final PropertyNameWrapper name to use for this element, if anystatic final ObjectMarker object used to indicate "do not serialize if empty"Fields inherited from class tools.jackson.databind.introspect.ConcreteBeanPropertyBase
_aliases, _metadataFields inherited from interface tools.jackson.databind.BeanProperty
EMPTY_FORMAT, EMPTY_INCLUDE -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedConstructor 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.BeanPropertyWriter(BeanPropertyDefinition propDef, AnnotatedMember member, Annotations contextAnnotations, JavaType declaredType, ValueSerializer<?> ser, TypeSerializer typeSer, JavaType serType, boolean suppressNulls, Object suppressableValue, Class<?>[] includeInViews) protected"Copy constructor" to be used by filtering sub-classesprotectedBeanPropertyWriter(BeanPropertyWriter base, SerializedString name) protectedBeanPropertyWriter(BeanPropertyWriter base, PropertyName name) -
Method Summary
Modifier and TypeMethodDescriptionprotected void_depositSchemaProperty(ObjectNode propertiesNode, JsonNode schemaNode) protected ValueSerializer<Object>_findAndAddDynamic(PropertySerializerMap map, Class<?> rawType, SerializationContext provider) protected boolean_handleSelfReference(Object bean, JsonGenerator g, SerializationContext ctxt, ValueSerializer<?> ser) Method called to handle a direct self-reference through this property.protected BeanPropertyWriter_new(PropertyName newName) Overridable factory method used by sub-classesvoidassignNullSerializer(ValueSerializer<Object> nullSer) Method called to assign null value serializer for propertyvoidMethod called to assign value serializer for propertyvoidassignTypeSerializer(TypeSerializer typeSer) Method called to set, reset or clear the configured type serializer for property.voidTraversal method used for things like JSON Schema generation, or POJO introspection.voidfixAccess(SerializationConfig config) Method called to ensure that the mutator has proper access rights to be called, as per configuration.final ObjectMethod that can be used to access value of the property this Object describes, from given bean instance.<A extends Annotation>
AgetAnnotation(Class<A> acls) Method for accessing annotations directly declared for property that this writer is associated with.<A extends Annotation>
AgetContextAnnotation(Class<A> acls) 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.getInternalSetting(Object key) Method for accessing value of specified internal setting.Method for accessing primary physical entity that represents the property; annotated field, method or constructor property.getName()getType()Method to get declared type of the property.Class<?>[]getViews()If property is indicated to be wrapped, name of wrapper element to use.booleanbooleanbooleanAccessor 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).Method for removing entry for specified internal setting.rename(NameTransformer transformer) voidserializeAsElement(Object bean, JsonGenerator g, SerializationContext ctxt) Alternative toserializeAsProperty(java.lang.Object, tools.jackson.core.JsonGenerator, tools.jackson.databind.SerializationContext)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.voidserializeAsOmittedElement(Object bean, JsonGenerator g, SerializationContext prov) 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.voidserializeAsOmittedProperty(Object bean, JsonGenerator g, SerializationContext ctxt) 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.voidserializeAsProperty(Object bean, JsonGenerator g, SerializationContext ctxt) 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.setInternalSetting(Object key, Object value) Method for setting specific internal setting to given valuevoidMethod called to define type to consider as "non-trivial" basetype, needed for dynamic serialization resolution for complex (usually container) typestoString()unwrappingWriter(NameTransformer unwrapper) Method called create an instance that handles details of unwrapping contained value.booleanbooleanMethod called to check to see if this property has a name that would conflict with a given name.Methods inherited from class tools.jackson.databind.ser.PropertyWriter
findAnnotationMethods inherited from class tools.jackson.databind.introspect.ConcreteBeanPropertyBase
findAliases, findFormatOverrides, findPropertyFormat, findPropertyInclusion, getMetadata, isRequired, isVirtualMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface tools.jackson.databind.util.FullyNamed
hasName
-
Field Details
-
MARKER_FOR_EMPTY
Marker object used to indicate "do not serialize if empty" -
_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.
-
_wrapperName
Wrapper name to use for this element, if any -
_declaredType
Type property is declared to have, either in class definition or associated annotations. -
_cfgSerializationType
Type to use for locating serializer; normally same as return type of the accessor method, but may be overridden by annotations. -
_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. -
_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.
-
_member
Member (field, method) that represents property and allows access to associated annotations. -
_accessor
protected final tools.jackson.databind.ser.BeanPropertyWriter.GetterHolder _accessorAccessor method used to get property value. Wrapped in a holder since MethodHandle is not serializable. -
_serializer
Serializer to use for writing out the value: null if it cannot be known statically; non-null if it can. -
_nullSerializer
Serializer used for writing out null values, if any: if null, null values are to be suppressed. -
_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). -
_dynamicSerializers
In case serializer is not known statically (i.e._serializeris null), we will use a lookup structure for storing dynamically resolved mapping from type(s) to serializer(s). -
_suppressNulls
protected final boolean _suppressNullsWhether 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. -
_suppressableValue
Value that is considered default value of the property; used for default-value-suppression if enabled. -
_includeInViews
Alternate set of property writers used when view-based filtering is available for the Bean. -
_internalSettings
-
-
Constructor Details
-
BeanPropertyWriter
public BeanPropertyWriter(BeanPropertyDefinition propDef, AnnotatedMember member, Annotations contextAnnotations, JavaType declaredType, ValueSerializer<?> ser, TypeSerializer typeSer, JavaType serType, boolean suppressNulls, Object suppressableValue, Class<?>[] includeInViews) -
BeanPropertyWriter
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. -
BeanPropertyWriter
"Copy constructor" to be used by filtering sub-classes -
BeanPropertyWriter
-
BeanPropertyWriter
-
-
Method Details
-
rename
-
_new
Overridable factory method used by sub-classes -
assignTypeSerializer
Method called to set, reset or clear the configured type serializer for property. -
assignSerializer
Method called to assign value serializer for property -
assignNullSerializer
Method called to assign null value serializer for property -
unwrappingWriter
Method called create an instance that handles details of unwrapping contained value. -
setNonTrivialBaseType
Method called to define type to consider as "non-trivial" basetype, needed for dynamic serialization resolution for complex (usually container) types -
fixAccess
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. -
getName
- Specified by:
getNamein interfaceNamed- Specified by:
getNamein classPropertyWriter
-
getFullName
- Specified by:
getFullNamein interfaceFullyNamed- Specified by:
getFullNamein classPropertyWriter
-
getType
Description copied from interface:BeanPropertyMethod to get declared type of the property. -
getWrapperName
Description copied from interface:BeanPropertyIf property is indicated to be wrapped, name of wrapper element to use. -
getAnnotation
Description copied from class:PropertyWriterMethod for accessing annotations directly declared for property that this writer is associated with.- Specified by:
getAnnotationin interfaceBeanProperty- Specified by:
getAnnotationin classPropertyWriter
-
getContextAnnotation
Description copied from class:PropertyWriterMethod for accessing annotations declared in context of the property that this writer is associated with; usually this means annotations on enclosing class for property.- Specified by:
getContextAnnotationin interfaceBeanProperty- Specified by:
getContextAnnotationin classPropertyWriter
-
getMember
Description copied from interface:BeanPropertyMethod for accessing primary physical entity that represents the property; annotated field, method or constructor property. -
_depositSchemaProperty
-
getInternalSetting
Method for accessing value of specified internal setting.- Returns:
- Value of the setting, if any; null if none.
-
setInternalSetting
Method for setting specific internal setting to given value- Returns:
- Old value of the setting, if any (null if none)
-
removeInternalSetting
Method for removing entry for specified internal setting.- Returns:
- Existing value of the setting, if any (null if none)
-
getSerializedName
-
hasSerializer
public boolean hasSerializer() -
hasNullSerializer
public boolean hasNullSerializer() -
getTypeSerializer
-
isUnwrapping
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.
-
willSuppressNulls
public boolean willSuppressNulls() -
wouldConflictWithName
Method called to check to see if this property has a name that would conflict with a given name.- Since:
- 2.6
-
getSerializer
-
getSerializationType
-
getViews
-
serializeAsProperty
public void serializeAsProperty(Object bean, JsonGenerator g, SerializationContext ctxt) throws Exception 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.- Specified by:
serializeAsPropertyin classPropertyWriter- Throws:
Exception
-
serializeAsOmittedProperty
public void serializeAsOmittedProperty(Object bean, JsonGenerator g, SerializationContext ctxt) throws Exception 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.- Specified by:
serializeAsOmittedPropertyin classPropertyWriter- Throws:
Exception
-
serializeAsElement
public void serializeAsElement(Object bean, JsonGenerator g, SerializationContext ctxt) throws Exception Alternative toserializeAsProperty(java.lang.Object, tools.jackson.core.JsonGenerator, tools.jackson.databind.SerializationContext)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.- Specified by:
serializeAsElementin classPropertyWriter- Throws:
Exception
-
serializeAsOmittedElement
public void serializeAsOmittedElement(Object bean, JsonGenerator g, SerializationContext prov) throws Exception 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.- Specified by:
serializeAsOmittedElementin classPropertyWriter- Throws:
Exception
-
depositSchemaProperty
Description copied from class:PropertyWriterTraversal method used for things like JSON Schema generation, or POJO introspection.- Specified by:
depositSchemaPropertyin interfaceBeanProperty- Specified by:
depositSchemaPropertyin classPropertyWriter- Parameters:
v- Visitor to used as the callback handler
-
_findAndAddDynamic
protected ValueSerializer<Object> _findAndAddDynamic(PropertySerializerMap map, Class<?> rawType, SerializationContext provider) -
get
Method that can be used to access value of the property this Object describes, from given bean instance.- Throws:
Exception
-
_handleSelfReference
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 throwingDatabindException; fully handle serialization (and return true); or indicate that it should be serialized normally (return false).Default implementation will throw
DatabindExceptionifSerializationFeature.FAIL_ON_SELF_REFERENCESis enabled; or returnfalseif it is disabled.- Returns:
- True if method fully handled self-referential value; false if not
(caller is to handle it) or
DatabindExceptionif there is no way handle it - Throws:
JacksonException
-
toString
-