Top Description Fields Constructors Methods
com.fasterxml.jackson.databind.ser.std

public Class CollectionSerializer

extends AsArraySerializerBase<Collection<?>>
Class Inheritance
Imports
java.io.IOException, java.util.Collection, .Iterator, com.fasterxml.jackson.core.*, com.fasterxml.jackson.databind.BeanProperty, .JavaType, .JsonSerializer, .SerializationFeature, .SerializerProvider, com.fasterxml.jackson.databind.jsontype.TypeSerializer, com.fasterxml.jackson.databind.ser.ContainerSerializer, com.fasterxml.jackson.databind.ser.impl.PropertySerializerMap

References Deprecated

AsArraySerializerBase is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

Fallback serializer for cases where Collection is not known to be of type for which more specializer serializer exists (such as index-accessible List). If so, we will just construct an java.util.Iterator to iterate over elements.

Field Summary

Modifier and TypeField and Description
private static final long
Inherited from com.fasterxml.jackson.databind.ser.std.AsArraySerializerBase:
_dynamicSerializers_elementSerializer_elementType_property_staticTyping_unwrapSingle_valueTypeSerializer

Constructor Summary

AccessConstructor and Description
public
CollectionSerializer(JavaType elemType, boolean staticTyping, TypeSerializer vts, JsonSerializer<Object> valueSerializer)

public
CollectionSerializer(JavaType elemType, boolean staticTyping, TypeSerializer vts, BeanProperty property, JsonSerializer<Object> valueSerializer)
Deprecated since 2.6

public
CollectionSerializer(CollectionSerializer src, BeanProperty property, TypeSerializer vts, JsonSerializer<?> valueSerializer, Boolean unwrapSingle)
References Deprecated CollectionSerializer is deprecated or references (maybe indirectly) at least one deprecated element.

Method Summary

Modifier and TypeMethod and Description
public ContainerSerializer<?>
_withValueTypeSerializer(TypeSerializer vts)

Implements abstract com.fasterxml.jackson.databind.ser.ContainerSerializer._withValueTypeSerializer.

References Deprecated ContainerSerializer is deprecated or references (maybe indirectly) at least one deprecated element.

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 boolean
hasSingleElement(Collection<?> value)

Implements abstract com.fasterxml.jackson.databind.ser.ContainerSerializer.hasSingleElement.

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

public boolean
isEmpty(SerializerProvider prov, Collection<?> value)

Overrides com.fasterxml.jackson.databind.JsonSerializer.isEmpty.

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

public final void
serialize(Collection<?>
Value to serialize; can not be null.
value
,
JsonGenerator
Generator used to output resulting Json content
g
,
SerializerProvider
Provider that can be used to get serializers for serializing Objects value contains, if any.
provider
)

Overrides com.fasterxml.jackson.databind.ser.std.AsArraySerializerBase.serialize.

Method that can be called to ask implementation to serialize values of type this serializer handles.

public void
public void
public CollectionSerializer
withResolved(BeanProperty property, TypeSerializer vts, JsonSerializer<?> elementSerializer, Boolean unwrapSingle)

Implements abstract com.fasterxml.jackson.databind.ser.std.AsArraySerializerBase.withResolved.

References Deprecated CollectionSerializer is deprecated or references (maybe indirectly) at least one deprecated element.

Inherited from com.fasterxml.jackson.databind.ser.std.AsArraySerializerBase:
_findAndAddDynamic_findAndAddDynamicacceptJsonFormatVisitorcreateContextualgetContentSerializergetContentTypegetSchemaserializeWithTypewithResolved

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

Hides com.fasterxml.jackson.databind.ser.std.StdSerializer.serialVersionUID.

Constructor Detail

CollectionSerializerback to summary
public CollectionSerializer(JavaType elemType, boolean staticTyping, TypeSerializer vts, JsonSerializer<Object> valueSerializer)
Since
2.6
CollectionSerializerback to summary
public CollectionSerializer(JavaType elemType, boolean staticTyping, TypeSerializer vts, BeanProperty property, JsonSerializer<Object> valueSerializer)

Deprecated

since 2.6

Annotations
@Deprecated
CollectionSerializerback to summary
public CollectionSerializer(CollectionSerializer src, BeanProperty property, TypeSerializer vts, JsonSerializer<?> valueSerializer, Boolean unwrapSingle)

References Deprecated

CollectionSerializer is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

Method Detail

_withValueTypeSerializerback to summary
public ContainerSerializer<?> _withValueTypeSerializer(TypeSerializer vts)

Implements abstract com.fasterxml.jackson.databind.ser.ContainerSerializer._withValueTypeSerializer.

Doc from com.fasterxml.jackson.databind.ser.ContainerSerializer._withValueTypeSerializer.

References Deprecated

ContainerSerializer is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

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.

Annotations
@Override
hasSingleElementback to summary
public boolean hasSingleElement(Collection<?> value)

Implements abstract com.fasterxml.jackson.databind.ser.ContainerSerializer.hasSingleElement.

Doc from com.fasterxml.jackson.databind.ser.ContainerSerializer.hasSingleElement.

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 as of now (2.9) this method is only called by serializer itself; and specifically is not used for non-array/collection types like Map or Map.Entry instances.

Annotations
@Override
isEmptyback to summary
public boolean isEmpty(SerializerProvider prov, Collection<?> value)

Overrides com.fasterxml.jackson.databind.JsonSerializer.isEmpty.

Doc from com.fasterxml.jackson.databind.JsonSerializer.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.

Note

replaces isEmpty(Object), which was deprecated in 2.5

Annotations
@Override
serializeback to summary
public final void serialize(Collection<?> value, JsonGenerator g, SerializerProvider provider) throws IOException

Overrides com.fasterxml.jackson.databind.ser.std.AsArraySerializerBase.serialize.

Doc from com.fasterxml.jackson.databind.JsonSerializer.serialize.

Method that can be called to ask implementation to serialize values of type this serializer handles.

Parameters
value:Collection<?>

Value to serialize; can not be null.

g:JsonGenerator

Generator used to output resulting Json content

provider:SerializerProvider

Provider that can be used to get serializers for serializing Objects value contains, if any.

Annotations
@Override
serializeContentsback to summary
public void serializeContents(Collection<?> value, JsonGenerator g, SerializerProvider provider) throws IOException

Implements abstract com.fasterxml.jackson.databind.ser.std.AsArraySerializerBase.serializeContents.

Annotations
@Override
serializeContentsUsingback to summary
public void serializeContentsUsing(Collection<?> value, JsonGenerator g, SerializerProvider provider, JsonSerializer<Object> ser) throws IOException
withResolvedback to summary
public CollectionSerializer withResolved(BeanProperty property, TypeSerializer vts, JsonSerializer<?> elementSerializer, Boolean unwrapSingle)

Implements abstract com.fasterxml.jackson.databind.ser.std.AsArraySerializerBase.withResolved.

References Deprecated

CollectionSerializer is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

Annotations
@Override