Top Description Fields Constructors Methods
tools.jackson.databind.ser

public Class BeanSerializer

extends BeanSerializerBase
Class Inheritance
Annotations
@JacksonStdImpl
Imports
java.util.Set, tools.jackson.core.JacksonException, .JsonGenerator, tools.jackson.databind.*, tools.jackson.databind.annotation.JacksonStdImpl, tools.jackson.databind.ser.bean.BeanAsArraySerializer, .BeanSerializerBase, .UnwrappingBeanSerializer, tools.jackson.databind.ser.impl.ObjectIdWriter, tools.jackson.databind.util.NameTransformer

Serializer class that can serialize Java objects that map to JSON Object output. Internally handling is mostly dealt with by a sequence of BeanPropertyWriters that will handle access value to serialize and call appropriate serializers to write out JSON.

Implementation Note

we will post-process resulting serializer, to figure out actual serializers for final types. This must be done from resolve method, and NOT from constructor; otherwise we could end up with an infinite loop.

Field Summary

Inherited from tools.jackson.databind.ser.bean.BeanSerializerBase:
_beanType_filteredProps_objectIdWriter_propertyFilterId_props_serializationShape_typeIdNAME_FOR_OBJECT_REFNO_PROPS

Constructor Summary

AccessConstructor and Description
public
BeanSerializer(JavaType type, BeanSerializerBuilder
Builder object that contains collected information that may be needed for serializer
builder
,
BeanPropertyWriter[]
Property writers used for actual serialization
properties
,
BeanPropertyWriter[] filteredProperties)

protected
BeanSerializer(BeanSerializerBase src)

Alternate copy constructor that can be used to construct standard BeanSerializer passing an instance of "compatible enough" source serializer.

protected
protected
BeanSerializer(BeanSerializerBase src, ObjectIdWriter objectIdWriter, Object filterId)

protected
BeanSerializer(BeanSerializerBase src, Set<String> toIgnore, Set<String> toInclude)

protected

Method Summary

Modifier and TypeMethod and Description
protected BeanSerializerBase
asArraySerializer()

Implements abstract tools.jackson.databind.ser.bean.BeanSerializerBase.asArraySerializer.

Implementation has to check whether as-array serialization is possible reliably; if (and only if) so, will construct a BeanAsArraySerializer, otherwise will return this serializer as is.

public static BeanSerializer
createDummy(JavaType forType, BeanSerializerBuilder builder)

Method for constructing dummy bean serializer; one that never outputs any properties

public void
serialize(Object bean, JsonGenerator gen, SerializationContext provider)

Implements abstract tools.jackson.databind.ser.bean.BeanSerializerBase.serialize.

Main serialization method that will delegate actual output to configured BeanPropertyWriter instances.

public ValueSerializer<Object>
unwrappingSerializer(NameTransformer unwrapper)

Implements abstract tools.jackson.databind.ser.bean.BeanSerializerBase.unwrappingSerializer.

Lets force sub-classes to implement this, to avoid accidental missing of handling...

protected BeanSerializerBase
withByNameInclusion(Set<String> toIgnore, Set<String> toInclude)

Implements abstract tools.jackson.databind.ser.bean.BeanSerializerBase.withByNameInclusion.

Mutant factory used for creating a new instance with additional set of properties to ignore or include (from properties this instance otherwise has)

public BeanSerializerBase
withFilterId(Object filterId)

Implements abstract tools.jackson.databind.ser.bean.BeanSerializerBase.withFilterId.

Mutant factory used for creating a new instance with different filter id (used with JsonFilter annotation)

public ValueSerializer<?>
withIgnoredProperties(Set<String> toIgnore)

Overrides tools.jackson.databind.ValueSerializer.withIgnoredProperties.

Mutant factory method called to create a new instance after excluding specified set of properties by name, if there is any.

public BeanSerializerBase
withObjectIdWriter(ObjectIdWriter objectIdWriter)

Implements abstract tools.jackson.databind.ser.bean.BeanSerializerBase.withObjectIdWriter.

Mutant factory used for creating a new instance with different ObjectIdWriter.

protected BeanSerializerBase
withProperties(BeanPropertyWriter[] properties, BeanPropertyWriter[] filteredProperties)

Implements abstract tools.jackson.databind.ser.bean.BeanSerializerBase.withProperties.

Mutant factory used for creating a new instance with modified set of properties

Inherited from tools.jackson.databind.ser.bean.BeanSerializerBase:
_serializeObjectId_serializeProperties_serializePropertiesFiltered_serializePropertiesMaybeView_serializePropertiesNoView_serializeWithObjectId_serializeWithObjectId_typeIdDefacceptJsonFormatVisitorcanCreateArraySerializercreateContextualfindConvertingSerializergetFilterIdhasViewPropertiespropertiespropertyCountresolveserializeWithTypetoStringusesObjectId

Constructor Detail

BeanSerializerback to summary
public BeanSerializer(JavaType type, BeanSerializerBuilder builder, BeanPropertyWriter[] properties, BeanPropertyWriter[] filteredProperties)
Parameters
builder:BeanSerializerBuilder

Builder object that contains collected information that may be needed for serializer

properties:BeanPropertyWriter[]

Property writers used for actual serialization

BeanSerializerback to summary
protected BeanSerializer(BeanSerializerBase src)

Alternate copy constructor that can be used to construct standard BeanSerializer passing an instance of "compatible enough" source serializer.

BeanSerializerback to summary
protected BeanSerializer(BeanSerializerBase src, ObjectIdWriter objectIdWriter)
BeanSerializerback to summary
protected BeanSerializer(BeanSerializerBase src, ObjectIdWriter objectIdWriter, Object filterId)
BeanSerializerback to summary
protected BeanSerializer(BeanSerializerBase src, Set<String> toIgnore, Set<String> toInclude)
BeanSerializerback to summary
protected BeanSerializer(BeanSerializerBase src, BeanPropertyWriter[] properties, BeanPropertyWriter[] filteredProperties)

Method Detail

asArraySerializerback to summary
protected BeanSerializerBase asArraySerializer()

Implements abstract tools.jackson.databind.ser.bean.BeanSerializerBase.asArraySerializer.

Implementation has to check whether as-array serialization is possible reliably; if (and only if) so, will construct a BeanAsArraySerializer, otherwise will return this serializer as is.

Annotations
@Override
createDummyback to summary
public static BeanSerializer createDummy(JavaType forType, BeanSerializerBuilder builder)

Method for constructing dummy bean serializer; one that never outputs any properties

serializeback to summary
public void serialize(Object bean, JsonGenerator gen, SerializationContext provider) throws JacksonException

Implements abstract tools.jackson.databind.ser.bean.BeanSerializerBase.serialize.

Main serialization method that will delegate actual output to configured BeanPropertyWriter instances.

Annotations
@Override
unwrappingSerializerback to summary
public ValueSerializer<Object> unwrappingSerializer(NameTransformer unwrapper)

Implements abstract tools.jackson.databind.ser.bean.BeanSerializerBase.unwrappingSerializer.

Doc from tools.jackson.databind.ser.bean.BeanSerializerBase.unwrappingSerializer.

Lets force sub-classes to implement this, to avoid accidental missing of handling...

Annotations
@Override
withByNameInclusionback to summary
protected BeanSerializerBase withByNameInclusion(Set<String> toIgnore, Set<String> toInclude)

Implements abstract tools.jackson.databind.ser.bean.BeanSerializerBase.withByNameInclusion.

Doc from tools.jackson.databind.ser.bean.BeanSerializerBase.withByNameInclusion.

Mutant factory used for creating a new instance with additional set of properties to ignore or include (from properties this instance otherwise has)

Annotations
@Override
withFilterIdback to summary
public BeanSerializerBase withFilterId(Object filterId)

Implements abstract tools.jackson.databind.ser.bean.BeanSerializerBase.withFilterId.

Doc from tools.jackson.databind.ser.bean.BeanSerializerBase.withFilterId.

Mutant factory used for creating a new instance with different filter id (used with JsonFilter annotation)

Annotations
@Override
withIgnoredPropertiesback to summary
public ValueSerializer<?> withIgnoredProperties(Set<String> toIgnore)

Overrides tools.jackson.databind.ValueSerializer.withIgnoredProperties.

Doc from tools.jackson.databind.ValueSerializer.withIgnoredProperties.

Mutant factory method called to create a new instance after excluding specified set of properties by name, if there is any.

Annotations
@Override
withObjectIdWriterback to summary
public BeanSerializerBase withObjectIdWriter(ObjectIdWriter objectIdWriter)

Implements abstract tools.jackson.databind.ser.bean.BeanSerializerBase.withObjectIdWriter.

Doc from tools.jackson.databind.ser.bean.BeanSerializerBase.withObjectIdWriter.

Mutant factory used for creating a new instance with different ObjectIdWriter.

Annotations
@Override
withPropertiesback to summary
protected BeanSerializerBase withProperties(BeanPropertyWriter[] properties, BeanPropertyWriter[] filteredProperties)

Implements abstract tools.jackson.databind.ser.bean.BeanSerializerBase.withProperties.

Doc from tools.jackson.databind.ser.bean.BeanSerializerBase.withProperties.

Mutant factory used for creating a new instance with modified set of properties

Annotations
@Override