Class BeanPropertyWriter
java.lang.Object
org.codehaus.jackson.map.ser.BeanPropertyWriter
- All Implemented Interfaces:
BeanProperty, Named
- Direct Known Subclasses:
UnwrappingBeanPropertyWriter
Base bean property handler class, which implements common parts of
reflection-based functionality for accessing a property value
and serializing it.
-
Nested Class Summary
Nested classes/interfaces inherited from interface BeanProperty
BeanProperty.Std -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final MethodAccessor method used to get property value, for method-accessible properties.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 FieldField that contains the property value for field-accessible properties.protected 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 parametrized.protected final JsonSerializer<Object> Serializer to use for writing out the value: null if it can not 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 booleanFlag to indicate that null values for this property are not to be written out.protected TypeSerializerIf property being serialized needs type information to be included this is the type serializer to use. -
Constructor Summary
ConstructorsModifierConstructorDescriptionBeanPropertyWriter(AnnotatedMember member, Annotations contextAnnotations, String name, JavaType declaredType, JsonSerializer<Object> ser, TypeSerializer typeSer, JavaType serType, Method m, Field f, boolean suppressNulls, Object suppressableValue) BeanPropertyWriter(AnnotatedMember member, Annotations contextAnnotations, SerializedString name, JavaType declaredType, JsonSerializer<Object> ser, TypeSerializer typeSer, JavaType serType, Method m, Field f, boolean suppressNulls, Object suppressableValue) protected"Copy constructor" to be used by filtering sub-classesprotectedBeanPropertyWriter(BeanPropertyWriter base, JsonSerializer<Object> ser) "Copy constructor" to be used by filtering sub-classes -
Method Summary
Modifier and TypeMethodDescriptionprotected JsonSerializer<Object> _findAndAddDynamic(PropertySerializerMap map, Class<?> type, SerializerProvider provider) protected void_reportSelfReference(Object bean) 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 finding annotation associated with this property; meaning annotation associated with one of entities used to access property.<A extends Annotation>
AgetContextAnnotation(Class<A> acls) Method for finding annotation associated with context of this property; usually class in which member is declared (or its subtype if processing subtype).Get the generic property type of this property writer.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()Method to get logical name of the propertyClass<?> Class<?> getType()Method to get declared type of the property.Class<?>[]getViews()booleanMethod for removing entry for specified internal setting.voidserializeAsField(Object bean, JsonGenerator jgen, SerializerProvider prov) 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) typesvoidMethod for defining which views to included value of this property in.toString()Method called create an instance that handles details of unwrapping contained value.Method that will construct and return a new writer that has same properties as this writer, but uses specified serializer instead of currently configured one (if any).
-
Field Details
-
_member
Member (field, method) that represents property and allows access to associated annotations.- Since:
- 1.7
-
_contextAnnotations
Annotations from context (most often, class that declares property, or in case of sub-class serializer, from that sub-class) -
_declaredType
Type property is declared to have, either in class definition or associated annotations. -
_accessorMethod
-
_field
Field that contains the property value for field-accessible properties. Null if and only if_accessorMethodis null. -
_internalSettings
-
_name
Logical name of the property; will be used as the field name under which value for the property is written. -
_cfgSerializationType
Type to use for locating serializer; normally same as return type of the accessor method, but may be overridden by annotations. -
_serializer
Serializer to use for writing out the value: null if it can not be known statically; non-null if it can. -
_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).- Since:
- 1.7
-
_suppressNulls
protected final boolean _suppressNullsFlag to indicate that null values for this property are not to be written out. That is, if property has value null, no entry will be written -
_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.- Since:
- 1.4
-
_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). -
_nonTrivialBaseType
Base type of the property, if the declared type is "non-trivial"; meaning it is either a structured type (collection, map, array), or parametrized. Used to retain type information about contained type, which is mostly necessary if type metadata is to be included.- Since:
- 1.5
-
-
Constructor Details
-
BeanPropertyWriter
public BeanPropertyWriter(AnnotatedMember member, Annotations contextAnnotations, String name, JavaType declaredType, JsonSerializer<Object> ser, TypeSerializer typeSer, JavaType serType, Method m, Field f, boolean suppressNulls, Object suppressableValue) -
BeanPropertyWriter
public BeanPropertyWriter(AnnotatedMember member, Annotations contextAnnotations, SerializedString name, JavaType declaredType, JsonSerializer<Object> ser, TypeSerializer typeSer, JavaType serType, Method m, Field f, boolean suppressNulls, Object suppressableValue) -
BeanPropertyWriter
"Copy constructor" to be used by filtering sub-classes -
BeanPropertyWriter
"Copy constructor" to be used by filtering sub-classes
-
-
Method Details
-
withSerializer
Method that will construct and return a new writer that has same properties as this writer, but uses specified serializer instead of currently configured one (if any). -
unwrappingWriter
Method called create an instance that handles details of unwrapping contained value.- Since:
- 1.9
-
setViews
Method for defining which views to included value of this property in. If left undefined, will always be included; otherwise active view definition will be checked against definition list and value is only included if active view is one of defined views, or its sub-view (as defined by class/sub-class relationship). -
setNonTrivialBaseType
Method called to define type to consider as "non-trivial" basetype, needed for dynamic serialization resolution for complex (usually container) types- Since:
- 1.5
-
getName
Description copied from interface:BeanPropertyMethod to get logical name of the property- Specified by:
getNamein interfaceBeanProperty- Specified by:
getNamein interfaceNamed
-
getType
Description copied from interface:BeanPropertyMethod to get declared type of the property.- Specified by:
getTypein interfaceBeanProperty
-
getAnnotation
Description copied from interface:BeanPropertyMethod for finding annotation associated with this property; meaning annotation associated with one of entities used to access property.- Specified by:
getAnnotationin interfaceBeanProperty
-
getContextAnnotation
Description copied from interface:BeanPropertyMethod for finding annotation associated with context of this property; usually class in which member is declared (or its subtype if processing subtype).- Specified by:
getContextAnnotationin interfaceBeanProperty
-
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
-
getInternalSetting
-
setInternalSetting
-
removeInternalSetting
-
getSerializedName
-
hasSerializer
public boolean hasSerializer() -
getSerializer
-
getSerializationType
-
getRawSerializationType
-
getPropertyType
-
getGenericPropertyType
Get the generic property type of this property writer.- Returns:
- The property type, or null if not found.
-
getViews
-
serializeAsField
public void serializeAsField(Object bean, JsonGenerator jgen, SerializerProvider prov) 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.- Throws:
Exception
-
_findAndAddDynamic
protected JsonSerializer<Object> _findAndAddDynamic(PropertySerializerMap map, Class<?> type, SerializerProvider provider) throws JsonMappingException - Throws:
JsonMappingException- Since:
- 1.7
-
get
Method that can be used to access value of the property this Object describes, from given bean instance.Note: method is final as it should not need to be overridden -- rather, calling method(s) (
serializeAsField(Object, JsonGenerator, SerializerProvider)) should be overridden to change the behavior- Throws:
Exception
-
_reportSelfReference
- Throws:
JsonMappingException
-
toString
-