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

public abstract Class StdContainerSerializer<T>

extends StdSerializer<T>
Class Inheritance
Known Direct Subclasses
tools.jackson.databind.ser.jdk.MapEntrySerializer, tools.jackson.databind.ser.jdk.MapSerializer, tools.jackson.databind.ser.std.ArraySerializerBase, tools.jackson.databind.ser.std.AsArraySerializerBase
Imports
tools.jackson.databind.*, tools.jackson.databind.jsontype.TypeSerializer, tools.jackson.databind.ser.impl.PropertySerializerMap

Intermediate base class for serializers used for serializing types that contain element(s) of other types, such as arrays, java.util.Collections (Lists, Sets etc) and java.util.Maps and iterable things (java.util.Iterators).

Note

in Jackson 2.x, this class was named ContainerSerializer (in package com.fasterxml.jackson.databind.ser).

Field Summary

Modifier and TypeField and Description
protected PropertySerializerMap
_dynamicValueSerializers

If value type cannot be statically determined, mapping from runtime value types to serializers are stored in this object.

protected final BeanProperty
_property

Property that contains values handled by this serializer, if known; `null` for root value serializers (ones directly called by ObjectMapper and ObjectWriter).

Inherited from tools.jackson.databind.ser.std.StdSerializer:
_handledType

Constructor Summary

AccessConstructor and Description
protected
protected
protected
protected
protected

Method Summary

Modifier and TypeMethod and Description
protected ValueSerializer<Object>
protected ValueSerializer<Object>
protected abstract StdContainerSerializer<?>
_withValueTypeSerializer(TypeSerializer vts)

Method that needs to be implemented to allow construction of a new serializer object with given TypeSerializer, used when addition type information is to be embedded.

public abstract ValueSerializer<?>
getContentSerializer()

Accessor for serializer used for serializing contents (List and array elements, Map values etc) of the container for which this serializer is used, if it is known statically.

public abstract JavaType
getContentType()

Accessor for finding declared (static) element type for type this serializer is used for.

public abstract boolean
hasSingleElement(T value)

Method called to determine if the given value (of type handled by this serializer) contains exactly one element.

public abstract boolean
isEmpty(SerializationContext prov, T value)

Overrides tools.jackson.databind.ValueSerializer.isEmpty.

Method called to check whether given serializable value is considered "empty" value (for purposes of suppressing serialization of empty values).

public StdContainerSerializer<?>

Returns:

Serializer instance that uses given type serializer for values if that is possible (or if not, just 'this' serializer)
withValueTypeSerializer
(TypeSerializer
Type serializer to use for contained values; can be null, in which case 'this' serializer is returned as is
vts
)

Factory(-like) method that can be used to construct a new container serializer that uses specified TypeSerializer for decorating contained values with additional type information.

Inherited from tools.jackson.databind.ser.std.StdSerializer:
_neitherNull_nonEmpty_wrapIOFailureacceptJsonFormatVisitoracceptJsonFormatVisitorForBinarycreateSchemaNodecreateSchemaNodefindAnnotatedContentSerializerfindContextualConvertingSerializerfindFormatFeaturefindFormatOverridesfindIncludeOverridesfindPropertyFilterhandledTypeisDefaultSerializerserializevisitArrayFormatvisitArrayFormatvisitFloatFormatvisitIntFormatvisitIntFormatvisitStringFormatvisitStringFormatwrapAndThrowwrapAndThrow

Field Detail

_dynamicValueSerializersback to summary
protected PropertySerializerMap _dynamicValueSerializers

If value type cannot be statically determined, mapping from runtime value types to serializers are stored in this object.

Since
3.0 (in 2.x subtypes contained it)
_propertyback to summary
protected final BeanProperty _property

Property that contains values handled by this serializer, if known; `null` for root value serializers (ones directly called by ObjectMapper and ObjectWriter).

Since
3.0

Constructor Detail

StdContainerSerializerback to summary
protected StdContainerSerializer(Class<?> t)
StdContainerSerializerback to summary
protected StdContainerSerializer(Class<?> t, BeanProperty prop)
StdContainerSerializerback to summary
protected StdContainerSerializer(JavaType fullType, BeanProperty prop)
StdContainerSerializerback to summary
protected StdContainerSerializer(StdContainerSerializer<?> src)
StdContainerSerializerback to summary
protected StdContainerSerializer(StdContainerSerializer<?> src, BeanProperty prop)

Method Detail

_findAndAddDynamicback to summary
protected ValueSerializer<Object> _findAndAddDynamic(SerializationContext ctxt, Class<?> type)
Since
3.0
_findAndAddDynamicback to summary
protected ValueSerializer<Object> _findAndAddDynamic(SerializationContext ctxt, JavaType type)
Since
3.0
_withValueTypeSerializerback to summary
protected abstract StdContainerSerializer<?> _withValueTypeSerializer(TypeSerializer vts)

Method that needs to be implemented to allow construction of a new serializer object with given TypeSerializer, used when addition type information is to be embedded.

getContentSerializerback to summary
public abstract ValueSerializer<?> getContentSerializer()

Accessor for serializer used for serializing contents (List and array elements, Map values etc) of the container for which this serializer is used, if it is known statically. Note that for dynamic types this may return null; if so, caller has to instead use getContentType() and tools.jackson.databind.SerializationContext#findContentValueSerializer.

getContentTypeback to summary
public abstract JavaType getContentType()

Accessor for finding declared (static) element type for type this serializer is used for.

hasSingleElementback to summary
public abstract boolean hasSingleElement(T value)

Method called to determine if the given value (of type handled by this serializer) contains exactly one element.

Note

although it might seem sensible to instead define something like "getElementCount()" method, this would not work well for containers that do not keep track of size (like linked lists may not).

Note, too, that this method is only called by serializer itself; and specifically is not used for non-array/collection types like Map or Map.Entry instances.

isEmptyback to summary
public abstract boolean isEmpty(SerializationContext prov, T value)

Overrides tools.jackson.databind.ValueSerializer.isEmpty.

Doc from tools.jackson.databind.ValueSerializer.isEmpty.

Method called to check whether given serializable value is considered "empty" value (for purposes of suppressing serialization of empty values).

Default implementation will consider only null values to be empty.

Annotations
@Override
withValueTypeSerializerback to summary
public StdContainerSerializer<?> withValueTypeSerializer(TypeSerializer vts)

Factory(-like) method that can be used to construct a new container serializer that uses specified TypeSerializer for decorating contained values with additional type information.

Parameters
vts:TypeSerializer

Type serializer to use for contained values; can be null, in which case 'this' serializer is returned as is

Returns:StdContainerSerializer<?>

Serializer instance that uses given type serializer for values if that is possible (or if not, just 'this' serializer)