public class BeanPropertyWriter extends Object implements BeanProperty
BeanProperty.Std
Modifier and Type | Field and Description |
---|---|
protected Method |
_accessorMethod
Accessor method used to get property value, for
method-accessible properties.
|
protected JavaType |
_cfgSerializationType
Type to use for locating serializer; normally same as return
type of the accessor method, but may be overridden by annotations.
|
protected Annotations |
_contextAnnotations
Annotations from context (most often, class that declares property,
or in case of sub-class serializer, from that sub-class)
|
protected JavaType |
_declaredType
Type property is declared to have, either in class definition
or associated annotations.
|
protected PropertySerializerMap |
_dynamicSerializers
In case serializer is not known statically (i.e.
|
protected Field |
_field
Field that contains the property value for field-accessible
properties.
|
protected Class<?>[] |
_includeInViews
Alternate set of property writers used when view-based filtering
is available for the Bean.
|
protected HashMap<Object,Object> |
_internalSettings |
protected AnnotatedMember |
_member
Member (field, method) that represents property and allows access
to associated annotations.
|
protected 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 parametrized.
|
protected JsonSerializer<Object> |
_serializer
Serializer to use for writing out the value: null if it can not
be known statically; non-null if it can.
|
protected Object |
_suppressableValue
Value that is considered default value of the property; used for
default-value-suppression if enabled.
|
protected boolean |
_suppressNulls
Flag to indicate that null values for this property are not
to be written out.
|
protected TypeSerializer |
_typeSerializer
If property being serialized needs type information to be
included this is the type serializer to use.
|
Modifier | Constructor and Description |
---|---|
|
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(AnnotatedMember member,
Annotations contextAnnotations,
String name,
JavaType declaredType,
JsonSerializer<Object> ser,
TypeSerializer typeSer,
JavaType serType,
Method m,
Field f,
boolean suppressNulls,
Object suppressableValue) |
protected |
BeanPropertyWriter(BeanPropertyWriter base)
"Copy constructor" to be used by filtering sub-classes
|
protected |
BeanPropertyWriter(BeanPropertyWriter base,
JsonSerializer<Object> ser)
"Copy constructor" to be used by filtering sub-classes
|
Modifier and Type | Method and Description |
---|---|
protected JsonSerializer<Object> |
_findAndAddDynamic(PropertySerializerMap map,
Class<?> type,
SerializerProvider provider) |
protected void |
_reportSelfReference(Object bean) |
Object |
get(Object bean)
Method that can be used to access value of the property this
Object describes, from given bean instance.
|
<A extends Annotation> |
getAnnotation(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> |
getContextAnnotation(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).
|
Type |
getGenericPropertyType()
Get the generic property type of this property writer.
|
Object |
getInternalSetting(Object key)
Method for accessing value of specified internal setting.
|
AnnotatedMember |
getMember()
Method for accessing primary physical entity that represents the property;
annotated field, method or constructor property.
|
String |
getName()
Method to get logical name of the property
|
Class<?> |
getPropertyType() |
Class<?> |
getRawSerializationType() |
JavaType |
getSerializationType() |
SerializedString |
getSerializedName() |
JsonSerializer<Object> |
getSerializer() |
JavaType |
getType()
Method to get declared type of the property.
|
Class<?>[] |
getViews() |
boolean |
hasSerializer() |
Object |
removeInternalSetting(Object key)
Method for removing entry for specified internal setting.
|
void |
serializeAsField(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.
|
Object |
setInternalSetting(Object key,
Object value)
Method for setting specific internal setting to given value
|
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
|
void |
setViews(Class<?>[] views)
Method for defining which views to included value of this
property in.
|
String |
toString() |
BeanPropertyWriter |
unwrappingWriter()
Method called create an instance that handles details of unwrapping
contained value.
|
BeanPropertyWriter |
withSerializer(JsonSerializer<Object> ser)
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).
|
protected final AnnotatedMember _member
protected final Annotations _contextAnnotations
protected final JavaType _declaredType
protected final Method _accessorMethod
_field
is null.protected final Field _field
_accessorMethod
is null.protected final SerializedString _name
protected final JavaType _cfgSerializationType
protected final JsonSerializer<Object> _serializer
protected PropertySerializerMap _dynamicSerializers
_serializer
is null), we will use a lookup structure for storing dynamically
resolved mapping from type(s) to serializer(s).protected final boolean _suppressNulls
protected final Object _suppressableValue
protected Class<?>[] _includeInViews
protected TypeSerializer _typeSerializer
protected JavaType _nonTrivialBaseType
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)
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)
protected BeanPropertyWriter(BeanPropertyWriter base)
protected BeanPropertyWriter(BeanPropertyWriter base, JsonSerializer<Object> ser)
public BeanPropertyWriter withSerializer(JsonSerializer<Object> ser)
public BeanPropertyWriter unwrappingWriter()
public void setViews(Class<?>[] views)
public void setNonTrivialBaseType(JavaType t)
public String getName()
BeanProperty
getName
in interface BeanProperty
getName
in interface Named
public JavaType getType()
BeanProperty
getType
in interface BeanProperty
public <A extends Annotation> A getAnnotation(Class<A> acls)
BeanProperty
getAnnotation
in interface BeanProperty
public <A extends Annotation> A getContextAnnotation(Class<A> acls)
BeanProperty
getContextAnnotation
in interface BeanProperty
public AnnotatedMember getMember()
BeanProperty
getMember
in interface BeanProperty
public Object getInternalSetting(Object key)
public Object setInternalSetting(Object key, Object value)
public Object removeInternalSetting(Object key)
public SerializedString getSerializedName()
public boolean hasSerializer()
public JsonSerializer<Object> getSerializer()
public JavaType getSerializationType()
public Class<?> getRawSerializationType()
public Class<?> getPropertyType()
public Type getGenericPropertyType()
public Class<?>[] getViews()
public void serializeAsField(Object bean, JsonGenerator jgen, SerializerProvider prov) throws Exception
Exception
protected JsonSerializer<Object> _findAndAddDynamic(PropertySerializerMap map, Class<?> type, SerializerProvider provider) throws JsonMappingException
JsonMappingException
public final Object get(Object bean) throws Exception
Note: method is final as it should not need to be overridden -- rather,
calling method(s) (serializeAsField(java.lang.Object, org.codehaus.jackson.JsonGenerator, org.codehaus.jackson.map.SerializerProvider)
) should be overridden
to change the behavior
Exception
protected void _reportSelfReference(Object bean) throws JsonMappingException
JsonMappingException