com.fasterxml.jackson.databind.ser

## Class PropertyBuilder

- java.lang.Object
- - com.fasterxml.jackson.databind.ser.PropertyBuilder

    public class PropertyBuilder
    extends Object

Helper class for `BeanSerializerFactory` that is used to construct `BeanPropertyWriter` instances. Can be sub-classed to change behavior.

### Field Summary

Fields
`protected AnnotationIntrospector` `_annotationIntrospector`
`protected BeanDescription` `_beanDesc`
`protected SerializationConfig` `_config`
`protected Object` `_defaultBean` If a property has serialization inclusion value of `JsonInclude.Include.NON_DEFAULT`, we may need to know the default value of the bean, to know if property value equals default one.
`protected JsonInclude.Value` `_defaultInclusion` Default inclusion mode for properties of the POJO for which properties are collected; possibly overridden on per-property basis.

### Constructor Summary

Constructors
Constructor and Description
`PropertyBuilder(SerializationConfig config, BeanDescription beanDesc)`

### Method Summary

Methods
`protected Object` `_throwWrapped(Exception e, String propName, 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 Object` `getDefaultBean()`
`protected Object` `getDefaultValue(JavaType type)` Accessor used to find out "default value" to use for comparing values to serialize, to determine whether to exclude value from serialization with inclusion type of `JsonInclude.Include.NON_DEFAULT`.
`protected Object` `getPropertyDefaultValue(String name, AnnotatedMember member, JavaType type)` 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 of `JsonInclude.Include.NON_EMPTY`.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### _config

    protected final SerializationConfig _config

#### _beanDesc

    protected final BeanDescription _beanDesc

#### _defaultInclusion

    protected final JsonInclude.Value _defaultInclusion

Default inclusion mode for properties of the POJO for which properties are collected; possibly overridden on per-property basis.

#### _annotationIntrospector

    protected final AnnotationIntrospector _annotationIntrospector

#### _defaultBean

    protected Object _defaultBean

If a property has serialization inclusion value of `JsonInclude.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.

### 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`

#### 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 Object getDefaultBean()

#### getPropertyDefaultValue

    protected Object getPropertyDefaultValue(String name,
                                 AnnotatedMember member,
                                 JavaType type)

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 of `JsonInclude.Include.NON_EMPTY`. 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

Since:
  2.7

#### getDefaultValue

    protected Object getDefaultValue(JavaType type)

Accessor used to find out "default value" to use for comparing values to serialize, to determine whether to exclude value from serialization with inclusion type of `JsonInclude.Include.NON_DEFAULT`.

Default logic is such that for primitives and wrapper types for primitives, expected defaults (0 for `int` and `java.lang.Integer`) are returned; for Strings, empty String, and for structured (Maps, Collections, arrays) and reference types, criteria `JsonInclude.Include.NON_DEFAULT` is used.

Since:
  2.7

#### _throwWrapped

    protected Object _throwWrapped(Exception e,
                       String propName,
                       Object defaultBean)