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

public abstract Class AsArraySerializerBase<T>

extends StdContainerSerializer<T>
Class Inheritance
Known Direct Subclasses
tools.jackson.databind.ser.jdk.CollectionSerializer, tools.jackson.databind.ser.jdk.EnumSetSerializer, tools.jackson.databind.ser.jdk.IndexedListSerializer, tools.jackson.databind.ser.jdk.IterableSerializer, tools.jackson.databind.ser.jdk.IteratorSerializer
Imports
java.util.Objects, com.fasterxml.jackson.annotation.JsonFormat, tools.jackson.core.*, tools.jackson.core.type.WritableTypeId, tools.jackson.databind.*, tools.jackson.databind.introspect.AnnotatedMember, tools.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper, tools.jackson.databind.jsontype.TypeSerializer

Base class for serializers that will output contents as JSON arrays; typically serializers used for java.util.Collection and array types.

Field Summary

Modifier and TypeField and Description
protected final ValueSerializer<Object>
_elementSerializer

Value serializer to use, if it can be statically determined

protected final JavaType
protected final boolean
protected final Boolean
_unwrapSingle

Setting for specific local override for "unwrap single element arrays": true for enable unwrapping, false for preventing it, `null` for using global configuration.

protected final TypeSerializer
_valueTypeSerializer

Type serializer used for values, if any.

Inherited from tools.jackson.databind.ser.std.StdContainerSerializer:
_dynamicValueSerializers_property

Constructor Summary

AccessConstructor and Description
protected
AsArraySerializerBase(Class<?> cls, JavaType elementType, boolean staticTyping, TypeSerializer vts, ValueSerializer<?> elementSerializer)

Non-contextual, "blueprint" constructor typically called when the first instance is created, without knowledge of property it was used via.

protected
AsArraySerializerBase(Class<?> cls, JavaType elementType, boolean staticTyping, TypeSerializer vts, ValueSerializer<?> elementSerializer, Boolean unwrapSingle)

General purpose constructor.

protected
AsArraySerializerBase(Class<?> cls, JavaType elementType, boolean staticTyping, TypeSerializer vts, ValueSerializer<?> elementSerializer, Boolean unwrapSingle, BeanProperty property)

General purpose constructor.

protected
AsArraySerializerBase(AsArraySerializerBase<?> src, TypeSerializer vts, ValueSerializer<?> elementSerializer, Boolean unwrapSingle, BeanProperty property)

Method Summary

Modifier and TypeMethod and Description
public void
public ValueSerializer<?>
createContextual(SerializationContext ctxt, BeanProperty property)

Overrides tools.jackson.databind.ValueSerializer.createContextual.

This method is needed to resolve contextual annotations like per-property overrides, as well as do recursive call to createContextual of content serializer, if known statically.

public ValueSerializer<?>
getContentSerializer()

Implements abstract tools.jackson.databind.ser.std.StdContainerSerializer.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 JavaType
getContentType()

Implements abstract tools.jackson.databind.ser.std.StdContainerSerializer.getContentType.

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

protected abstract void
public void
serializeWithType(T value, JsonGenerator g, SerializationContext ctxt, TypeSerializer typeSer)

Overrides tools.jackson.databind.ValueSerializer.serializeWithType.

Method that can be called to ask implementation to serialize values of type this serializer handles, using specified type serializer for embedding necessary type information.

protected abstract AsArraySerializerBase<T>
withResolved(BeanProperty property, TypeSerializer vts, ValueSerializer<?> elementSerializer, Boolean unwrapSingle)

Inherited from tools.jackson.databind.ser.std.StdContainerSerializer:
_findAndAddDynamic_findAndAddDynamic_withValueTypeSerializerhasSingleElementisEmptywithValueTypeSerializer

Field Detail

_elementSerializerback to summary
protected final ValueSerializer<Object> _elementSerializer

Value serializer to use, if it can be statically determined

_elementTypeback to summary
protected final JavaType _elementType
_staticTypingback to summary
protected final boolean _staticTyping
_unwrapSingleback to summary
protected final Boolean _unwrapSingle

Setting for specific local override for "unwrap single element arrays": true for enable unwrapping, false for preventing it, `null` for using global configuration.

_valueTypeSerializerback to summary
protected final TypeSerializer _valueTypeSerializer

Type serializer used for values, if any.

Constructor Detail

AsArraySerializerBaseback to summary
protected AsArraySerializerBase(Class<?> cls, JavaType elementType, boolean staticTyping, TypeSerializer vts, ValueSerializer<?> elementSerializer)

Non-contextual, "blueprint" constructor typically called when the first instance is created, without knowledge of property it was used via.

AsArraySerializerBaseback to summary
protected AsArraySerializerBase(Class<?> cls, JavaType elementType, boolean staticTyping, TypeSerializer vts, ValueSerializer<?> elementSerializer, Boolean unwrapSingle)

General purpose constructor. Use contextual constructors, if possible.

Annotations
@SuppressWarnings:unchecked
AsArraySerializerBaseback to summary
protected AsArraySerializerBase(Class<?> cls, JavaType elementType, boolean staticTyping, TypeSerializer vts, ValueSerializer<?> elementSerializer, Boolean unwrapSingle, BeanProperty property)

General purpose constructor. Use contextual constructors, if possible.

Annotations
@SuppressWarnings:unchecked
AsArraySerializerBaseback to summary
protected AsArraySerializerBase(AsArraySerializerBase<?> src, TypeSerializer vts, ValueSerializer<?> elementSerializer, Boolean unwrapSingle, BeanProperty property)
Annotations
@SuppressWarnings:unchecked

Method Detail

acceptJsonFormatVisitorback to summary
public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JacksonException

Overrides tools.jackson.databind.ser.std.StdSerializer.acceptJsonFormatVisitor.

Implements tools.jackson.databind.jsonFormatVisitors.JsonFormatVisitable.acceptJsonFormatVisitor.

Doc from tools.jackson.databind.ser.std.StdSerializer.acceptJsonFormatVisitor.

Default implementation specifies no format. This behavior is usually overriden by custom serializers.

Annotations
@Override
createContextualback to summary
public ValueSerializer<?> createContextual(SerializationContext ctxt, BeanProperty property)

Overrides tools.jackson.databind.ValueSerializer.createContextual.

This method is needed to resolve contextual annotations like per-property overrides, as well as do recursive call to createContextual of content serializer, if known statically.

Annotations
@Override
getContentSerializerback to summary
public ValueSerializer<?> getContentSerializer()

Implements abstract tools.jackson.databind.ser.std.StdContainerSerializer.getContentSerializer.

Doc from tools.jackson.databind.ser.std.StdContainerSerializer.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.

Annotations
@Override
getContentTypeback to summary
public JavaType getContentType()

Implements abstract tools.jackson.databind.ser.std.StdContainerSerializer.getContentType.

Doc from tools.jackson.databind.ser.std.StdContainerSerializer.getContentType.

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

Annotations
@Override
serializeContentsback to summary
protected abstract void serializeContents(T value, JsonGenerator gen, SerializationContext provider) throws JacksonException
serializeWithTypeback to summary
public void serializeWithType(T value, JsonGenerator g, SerializationContext ctxt, TypeSerializer typeSer) throws JacksonException

Overrides tools.jackson.databind.ValueSerializer.serializeWithType.

Doc from tools.jackson.databind.ValueSerializer.serializeWithType.

Method that can be called to ask implementation to serialize values of type this serializer handles, using specified type serializer for embedding necessary type information.

Default implementation will throw UnsupportedOperationException to indicate that proper type handling needs to be implemented.

For simple datatypes written as a single scalar value (JSON String, Number, Boolean), implementation would look like:

  // note: method to call depends on whether this type is serialized as JSON scalar, object or Array!
  typeSer.writeTypePrefixForScalar(value, gen);
  serialize(value, gen, provider);
  typeSer.writeTypeSuffixForScalar(value, gen);
and implementations for type serialized as JSON Arrays or Objects would differ slightly, as START-ARRAY/END-ARRAY and START-OBJECT/END-OBJECT pairs need to be properly handled with respect to serializing of contents.
Annotations
@Override
withResolvedback to summary
protected abstract AsArraySerializerBase<T> withResolved(BeanProperty property, TypeSerializer vts, ValueSerializer<?> elementSerializer, Boolean unwrapSingle)