Class PropertyBuilder
- java.lang.Object
-
- com.fasterxml.jackson.databind.ser.PropertyBuilder
-
public class PropertyBuilder extends java.lang.Object
Helper class forBeanSerializerFactory
that is used to constructBeanPropertyWriter
instances. Can be sub-classed to change behavior.
-
-
Field Summary
Fields Modifier and Type Field Description protected AnnotationIntrospector
_annotationIntrospector
protected BeanDescription
_beanDesc
protected SerializationConfig
_config
protected java.lang.Object
_defaultBean
If a property has serialization inclusion value ofJsonInclude.Include.NON_DEFAULT
, we may need to know the default value of the bean, to know if property value equals default one.protected com.fasterxml.jackson.annotation.JsonInclude.Value
_defaultInclusion
Default inclusion mode for properties of the POJO for which properties are collected; possibly overridden on per-property basis.protected boolean
_useRealPropertyDefaults
Marker flag used to indicate that "real" default values are to be used for properties, as per per-type value inclusion of typeNON_DEFAULT
-
Constructor Summary
Constructors Constructor Description PropertyBuilder(SerializationConfig config, BeanDescription beanDesc)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected BeanPropertyWriter
_constructPropertyWriter(BeanPropertyDefinition propDef, AnnotatedMember member, Annotations contextAnnotations, JavaType declaredType, JsonSerializer<?> ser, TypeSerializer typeSer, JavaType serType, boolean suppressNulls, java.lang.Object suppressableValue, java.lang.Class<?>[] includeInViews)
Overridable factory method for actual construction ofBeanPropertyWriter
; often needed if subclassingbuildWriter(com.fasterxml.jackson.databind.SerializerProvider, com.fasterxml.jackson.databind.introspect.BeanPropertyDefinition, com.fasterxml.jackson.databind.JavaType, com.fasterxml.jackson.databind.JsonSerializer<?>, com.fasterxml.jackson.databind.jsontype.TypeSerializer, com.fasterxml.jackson.databind.jsontype.TypeSerializer, com.fasterxml.jackson.databind.introspect.AnnotatedMember, boolean)
method.protected java.lang.Object
_throwWrapped(java.lang.Exception e, java.lang.String propName, java.lang.Object defaultBean)
protected BeanPropertyWriter
buildWriter(SerializerProvider prov, BeanPropertyDefinition propDef, JavaType declaredType, JsonSerializer<?> ser, TypeSerializer typeSer, TypeSerializer contentTypeSer, AnnotatedMember am, boolean defaultUseStaticTyping)
protected JavaType
findSerializationType(Annotated a, boolean useStaticTyping, JavaType declaredType)
Method that will try to determine statically defined type of property being serialized, based on annotations (for overrides), and alternatively declared type (if static typing for serialization is enabled).Annotations
getClassAnnotations()
protected java.lang.Object
getDefaultBean()
protected java.lang.Object
getDefaultValue(JavaType type)
Deprecated.Since 2.9protected java.lang.Object
getPropertyDefaultValue(java.lang.String name, AnnotatedMember member, JavaType type)
Deprecated.Since 2.9 since this will not allow determining difference between "no default instance" case and default being `null`.
-
-
-
Field Detail
-
_config
protected final SerializationConfig _config
-
_beanDesc
protected final BeanDescription _beanDesc
-
_annotationIntrospector
protected final AnnotationIntrospector _annotationIntrospector
-
_defaultBean
protected java.lang.Object _defaultBean
If a property has serialization inclusion value ofJsonInclude.Include.NON_DEFAULT
, we may need to know the default value of the bean, to know if property value equals default one.NOTE: only used if enclosing class defines NON_DEFAULT, but NOT if it is the global default OR per-property override.
-
_defaultInclusion
protected final com.fasterxml.jackson.annotation.JsonInclude.Value _defaultInclusion
Default inclusion mode for properties of the POJO for which properties are collected; possibly overridden on per-property basis. Combines global inclusion defaults and per-type (annotation and type-override) inclusion overrides.
-
_useRealPropertyDefaults
protected final boolean _useRealPropertyDefaults
Marker flag used to indicate that "real" default values are to be used for properties, as per per-type value inclusion of typeNON_DEFAULT
- Since:
- 2.8
-
-
Constructor Detail
-
PropertyBuilder
public PropertyBuilder(SerializationConfig config, BeanDescription beanDesc)
-
-
Method Detail
-
getClassAnnotations
public Annotations getClassAnnotations()
-
buildWriter
protected BeanPropertyWriter buildWriter(SerializerProvider prov, BeanPropertyDefinition propDef, JavaType declaredType, JsonSerializer<?> ser, TypeSerializer typeSer, TypeSerializer contentTypeSer, AnnotatedMember am, boolean defaultUseStaticTyping) throws JsonMappingException
- Parameters:
contentTypeSer
- Optional explicit type information serializer to use for contained values (only used for properties that are of container type)- Throws:
JsonMappingException
-
_constructPropertyWriter
protected BeanPropertyWriter _constructPropertyWriter(BeanPropertyDefinition propDef, AnnotatedMember member, Annotations contextAnnotations, JavaType declaredType, JsonSerializer<?> ser, TypeSerializer typeSer, JavaType serType, boolean suppressNulls, java.lang.Object suppressableValue, java.lang.Class<?>[] includeInViews) throws JsonMappingException
Overridable factory method for actual construction ofBeanPropertyWriter
; often needed if subclassingbuildWriter(com.fasterxml.jackson.databind.SerializerProvider, com.fasterxml.jackson.databind.introspect.BeanPropertyDefinition, com.fasterxml.jackson.databind.JavaType, com.fasterxml.jackson.databind.JsonSerializer<?>, com.fasterxml.jackson.databind.jsontype.TypeSerializer, com.fasterxml.jackson.databind.jsontype.TypeSerializer, com.fasterxml.jackson.databind.introspect.AnnotatedMember, boolean)
method.- Throws:
JsonMappingException
- Since:
- 2.12
-
findSerializationType
protected JavaType findSerializationType(Annotated a, boolean useStaticTyping, JavaType declaredType) throws JsonMappingException
Method that will try to determine statically defined type of property being serialized, based on annotations (for overrides), and alternatively declared type (if static typing for serialization is enabled). If neither can be used (no annotations, dynamic typing), returns null.- Throws:
JsonMappingException
-
getDefaultBean
protected java.lang.Object getDefaultBean()
-
getPropertyDefaultValue
@Deprecated protected java.lang.Object getPropertyDefaultValue(java.lang.String name, AnnotatedMember member, JavaType type)
Deprecated.Since 2.9 since this will not allow determining difference between "no default instance" case and default being `null`.Accessor used to find out "default value" for given property, to use for comparing values to serialize, to determine whether to exclude value from serialization with inclusion type ofJsonInclude.Include.NON_DEFAULT
. This method is called when we specifically want to know default value within context of a POJO, when annotation is within containing class, and not for property or defined as global baseline.Note that returning of pseudo-type
JsonInclude.Include.NON_EMPTY
requires special handling.- Since:
- 2.7
-
getDefaultValue
@Deprecated protected java.lang.Object getDefaultValue(JavaType type)
Deprecated.Since 2.9
-
_throwWrapped
protected java.lang.Object _throwWrapped(java.lang.Exception e, java.lang.String propName, java.lang.Object defaultBean)
-
-