Class BeanPropertyWriter
- All Implemented Interfaces:
BeanProperty
,Named
,Serializable
- Direct Known Subclasses:
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.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface edu.internet2.middleware.grouperClientExt.com.fasterxml.jackson.databind.BeanProperty
BeanProperty.Bogus, BeanProperty.Std
-
Field Summary
Modifier and TypeFieldDescriptionprotected Method
Accessor method used to get property value, for method-accessible properties.protected final JavaType
Type to use for locating serializer; normally same as return type of the accessor method, but may be overridden by annotations.protected final Annotations
Annotations from context (most often, class that declares property, or in case of sub-class serializer, from that sub-class)protected final JavaType
Type property is declared to have, either in class definition or associated annotations.protected PropertySerializerMap
In case serializer is not known statically (i.e.protected Field
Field that contains the property value for field-accessible properties.protected final Class<?>[]
Alternate set of property writers used when view-based filtering is available for the Bean.protected final AnnotatedMember
Member (field, method) that represents property and allows access to associated annotations.protected final SerializedString
Logical name of the property; will be used as the field name under which value for the property is written.protected JavaType
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 JsonSerializer<Object>
Serializer used for writing out null values, if any: if null, null values are to be suppressed.protected JsonSerializer<Object>
Serializer to use for writing out the value: null if it cannot be known statically; non-null if it can.protected final Object
Value that is considered default value of the property; used for default-value-suppression if enabled.protected final boolean
Whether null values are to be suppressed (nothing written out if value is null) or not.protected TypeSerializer
If property being serialized needs type information to be included this is the type serializer to use.protected final PropertyName
Wrapper name to use for this element, if anystatic final Object
Marker object used to indicate "do not serialize if empty"Fields inherited from class edu.internet2.middleware.grouperClientExt.com.fasterxml.jackson.databind.introspect.ConcreteBeanPropertyBase
_aliases, _metadata
Fields inherited from interface edu.internet2.middleware.grouperClientExt.com.fasterxml.jackson.databind.BeanProperty
EMPTY_FORMAT, EMPTY_INCLUDE
-
Constructor Summary
ModifierConstructorDescriptionprotected
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
(BeanPropertyDefinition propDef, AnnotatedMember member, Annotations contextAnnotations, JavaType declaredType, JsonSerializer<?> ser, TypeSerializer typeSer, JavaType serType, boolean suppressNulls, Object suppressableValue) Deprecated.BeanPropertyWriter
(BeanPropertyDefinition propDef, AnnotatedMember member, Annotations contextAnnotations, JavaType declaredType, JsonSerializer<?> ser, TypeSerializer typeSer, JavaType serType, boolean suppressNulls, Object suppressableValue, Class<?>[] includeInViews) protected
"Copy constructor" to be used by filtering sub-classesprotected
BeanPropertyWriter
(BeanPropertyWriter base, SerializedString name) protected
BeanPropertyWriter
(BeanPropertyWriter base, PropertyName name) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
_depositSchemaProperty
(ObjectNode propertiesNode, JsonNode schemaNode) protected JsonSerializer<Object>
_findAndAddDynamic
(PropertySerializerMap map, Class<?> type, SerializerProvider provider) protected boolean
_handleSelfReference
(Object bean, JsonGenerator gen, SerializerProvider prov, JsonSerializer<?> ser) Method called to handle a direct self-reference through this property.protected BeanPropertyWriter
_new
(PropertyName newName) Overridable factory method used by sub-classesvoid
assignNullSerializer
(JsonSerializer<Object> nullSer) Method called to assign null value serializer for propertyvoid
Method called to assign value serializer for propertyvoid
assignTypeSerializer
(TypeSerializer typeSer) Method called to set, reset or clear the configured type serializer for property.void
Traversal method used for things like JSON Schema generation, or POJO introspection.void
depositSchemaProperty
(ObjectNode propertiesNode, SerializerProvider provider) Deprecated.void
fixAccess
(SerializationConfig config) Method called to ensure that the mutator has proper access rights to be called, as per configuration.final Object
Method 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.Method for getting full name definition, including possible format-specific additional properties (such as namespace when using XML backend).Deprecated.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<?>
Deprecated.Since 2.7, to be removed from 2.9, usegetType()
instead.Class<?>
Deprecated.getType()
Method to get declared type of the property.Class<?>[]
getViews()
If property is indicated to be wrapped, name of wrapper element to use.boolean
boolean
boolean
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).Method for removing entry for specified internal setting.rename
(NameTransformer transformer) void
serializeAsElement
(Object bean, JsonGenerator gen, SerializerProvider prov) Alternative toserializeAsField(java.lang.Object, edu.internet2.middleware.grouperClientExt.com.fasterxml.jackson.core.JsonGenerator, edu.internet2.middleware.grouperClientExt.com.fasterxml.jackson.databind.SerializerProvider)
that is used when a POJO is serialized as JSON Array; the difference is that no field names are written.void
serializeAsField
(Object bean, JsonGenerator gen, 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.void
serializeAsOmittedField
(Object bean, JsonGenerator gen, SerializerProvider prov) 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.void
serializeAsPlaceholder
(Object bean, JsonGenerator gen, SerializerProvider 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.setInternalSetting
(Object key, Object value) Method for setting specific internal setting to given valuevoid
Method 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.boolean
boolean
Method called to check to see if this property has a name that would conflict with a given name.Methods inherited from class edu.internet2.middleware.grouperClientExt.com.fasterxml.jackson.databind.ser.PropertyWriter
findAnnotation
Methods inherited from class edu.internet2.middleware.grouperClientExt.com.fasterxml.jackson.databind.introspect.ConcreteBeanPropertyBase
findAliases, findFormatOverrides, findPropertyFormat, findPropertyInclusion, getMetadata, isRequired, isVirtual
-
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- Since:
- 2.2
-
_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. -
_accessorMethod
Accessor method used to get property value, for method-accessible properties. Null if and only if_field
is null.`transient` (and non-final) only to support JDK serializability.
-
_field
Field that contains the property value for field-accessible properties. Null if and only if_accessorMethod
is null.`transient` (and non-final) only to support JDK serializability.
-
_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._serializer
is 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, JsonSerializer<?> ser, TypeSerializer typeSer, JavaType serType, boolean suppressNulls, Object suppressableValue, Class<?>[] includeInViews) - Since:
- 2.9 (added `includeInViews` since 2.8)
-
BeanPropertyWriter
@Deprecated public BeanPropertyWriter(BeanPropertyDefinition propDef, AnnotatedMember member, Annotations contextAnnotations, JavaType declaredType, JsonSerializer<?> ser, TypeSerializer typeSer, JavaType serType, boolean suppressNulls, Object suppressableValue) Deprecated. -
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.- Since:
- 2.5
-
BeanPropertyWriter
"Copy constructor" to be used by filtering sub-classes -
BeanPropertyWriter
- Since:
- 2.5
-
BeanPropertyWriter
-
-
Method Details
-
rename
-
_new
Overridable factory method used by sub-classes- Since:
- 2.6
-
assignTypeSerializer
Method called to set, reset or clear the configured type serializer for property.- Since:
- 2.6
-
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.- Since:
- 2.8.3
-
getName
Description copied from interface:BeanProperty
Method to get logical name of the property- Specified by:
getName
in interfaceBeanProperty
- Specified by:
getName
in interfaceNamed
- Specified by:
getName
in classPropertyWriter
-
getFullName
Description copied from interface:BeanProperty
Method for getting full name definition, including possible format-specific additional properties (such as namespace when using XML backend).- Specified by:
getFullName
in interfaceBeanProperty
- Specified by:
getFullName
in classPropertyWriter
-
getType
Description copied from interface:BeanProperty
Method to get declared type of the property.- Specified by:
getType
in interfaceBeanProperty
-
getWrapperName
Description copied from interface:BeanProperty
If property is indicated to be wrapped, name of wrapper element to use.- Specified by:
getWrapperName
in interfaceBeanProperty
-
getAnnotation
Description copied from class:PropertyWriter
Method for accessing annotations directly declared for property that this writer is associated with.- Specified by:
getAnnotation
in interfaceBeanProperty
- Specified by:
getAnnotation
in classPropertyWriter
-
getContextAnnotation
Description copied from class:PropertyWriter
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.- Specified by:
getContextAnnotation
in interfaceBeanProperty
- Specified by:
getContextAnnotation
in classPropertyWriter
-
getMember
Description copied from interface:BeanProperty
Method for accessing primary physical entity that represents the property; annotated field, method or constructor property.- Specified by:
getMember
in interfaceBeanProperty
-
_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
- Since:
- 2.6
-
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.
- Since:
- 2.3
-
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
-
getRawSerializationType
Deprecated. -
getPropertyType
Deprecated.Since 2.7, to be removed from 2.9, usegetType()
instead. -
getGenericPropertyType
Deprecated.Since 2.7, to be removed from 2.9, usegetType()
instead.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 gen, 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.- Specified by:
serializeAsField
in classPropertyWriter
- Throws:
Exception
-
serializeAsOmittedField
public void serializeAsOmittedField(Object bean, JsonGenerator gen, SerializerProvider prov) 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:
serializeAsOmittedField
in classPropertyWriter
- Throws:
Exception
- Since:
- 2.3
-
serializeAsElement
public void serializeAsElement(Object bean, JsonGenerator gen, SerializerProvider prov) throws Exception Alternative toserializeAsField(java.lang.Object, edu.internet2.middleware.grouperClientExt.com.fasterxml.jackson.core.JsonGenerator, edu.internet2.middleware.grouperClientExt.com.fasterxml.jackson.databind.SerializerProvider)
that is used when a POJO is serialized as JSON Array; the difference is that no field names are written.- Specified by:
serializeAsElement
in classPropertyWriter
- Throws:
Exception
- Since:
- 2.3
-
serializeAsPlaceholder
public void serializeAsPlaceholder(Object bean, JsonGenerator gen, SerializerProvider 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:
serializeAsPlaceholder
in classPropertyWriter
- Throws:
Exception
- Since:
- 2.1
-
depositSchemaProperty
public void depositSchemaProperty(JsonObjectFormatVisitor v, SerializerProvider provider) throws JsonMappingException Description copied from class:PropertyWriter
Traversal method used for things like JSON Schema generation, or POJO introspection.- Specified by:
depositSchemaProperty
in interfaceBeanProperty
- Specified by:
depositSchemaProperty
in classPropertyWriter
- Parameters:
v
- Visitor to used as the callback handler- Throws:
JsonMappingException
-
depositSchemaProperty
@Deprecated public void depositSchemaProperty(ObjectNode propertiesNode, SerializerProvider provider) throws JsonMappingException Deprecated.Attempt to add the output of the givenBeanPropertyWriter
in the givenObjectNode
. Otherwise, add the default schemaJsonNode
in place of the writer's output- Specified by:
depositSchemaProperty
in classPropertyWriter
- Parameters:
propertiesNode
- Node which the given property would exist withinprovider
- Provider that can be used for accessing dynamic aspects of serialization processing- Throws:
JsonMappingException
-
_findAndAddDynamic
protected JsonSerializer<Object> _findAndAddDynamic(PropertySerializerMap map, Class<?> type, SerializerProvider provider) throws JsonMappingException - Throws:
JsonMappingException
-
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(java.lang.Object, edu.internet2.middleware.grouperClientExt.com.fasterxml.jackson.core.JsonGenerator, edu.internet2.middleware.grouperClientExt.com.fasterxml.jackson.databind.SerializerProvider)
) should be overridden to change the behavior- Throws:
Exception
-
_handleSelfReference
protected boolean _handleSelfReference(Object bean, JsonGenerator gen, SerializerProvider prov, JsonSerializer<?> ser) throws IOException Method called to handle a direct self-reference through this property. Method can choose to indicate an error by throwingJsonMappingException
; fully handle serialization (and return true); or indicate that it should be serialized normally (return false).Default implementation will throw
JsonMappingException
ifSerializationFeature.FAIL_ON_SELF_REFERENCES
is enabled; or returnfalse
if it is disabled.- Returns:
- True if method fully handled self-referential value; false if not
(caller is to handle it) or
JsonMappingException
if there is no way handle it - Throws:
IOException
-
toString
-
getType()
instead.