Module tools.jackson.databind
Package tools.jackson.databind.ser.std
Class StdContainerSerializer<T>
java.lang.Object
tools.jackson.databind.ValueSerializer<T>
tools.jackson.databind.ser.std.StdSerializer<T>
tools.jackson.databind.ser.std.StdContainerSerializer<T>
- All Implemented Interfaces:
JsonFormatVisitable
- Direct Known Subclasses:
ArraySerializerBase,AsArraySerializerBase,MapEntrySerializer,MapSerializer
Intermediate base class for serializers used for serializing
types that contain element(s) of other types, such as arrays,
Collections (Lists, Sets
etc) and Maps and iterable things
(Iterators).
NOTE: in Jackson 2.x, this class was named ContainerSerializer
(in package com.fasterxml.jackson.databind.ser).
-
Nested Class Summary
Nested classes/interfaces inherited from class tools.jackson.databind.ValueSerializer
ValueSerializer.None -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected PropertySerializerMapIf value type cannot be statically determined, mapping from runtime value types to serializers are stored in this object.protected final BeanPropertyProperty that contains values handled by this serializer, if known; `null` for root value serializers (ones directly called byObjectMapperandObjectWriter).Fields inherited from class tools.jackson.databind.ser.std.StdSerializer
_handledType -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedStdContainerSerializer(Class<?> t) protectedStdContainerSerializer(Class<?> t, BeanProperty prop) protectedStdContainerSerializer(JavaType fullType, BeanProperty prop) protectedprotectedStdContainerSerializer(StdContainerSerializer<?> src, BeanProperty prop) -
Method Summary
Modifier and TypeMethodDescriptionprotected ValueSerializer<Object>_findAndAddDynamic(SerializationContext ctxt, Class<?> type) protected ValueSerializer<Object>_findAndAddDynamic(SerializationContext ctxt, JavaType type) protected abstract StdContainerSerializer<?>Method that needs to be implemented to allow construction of a new serializer object with givenTypeSerializer, used when addition type information is to be embedded.abstract ValueSerializer<?>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.abstract JavaTypeAccessor for finding declared (static) element type for type this serializer is used for.abstract booleanhasSingleElement(T value) Method called to determine if the given value (of type handled by this serializer) contains exactly one element.abstract booleanisEmpty(SerializationContext prov, T value) Method called to check whether given serializable value is considered "empty" value (for purposes of suppressing serialization of empty values).Factory(-like) method that can be used to construct a new container serializer that uses specifiedTypeSerializerfor decorating contained values with additional type information.Methods inherited from class tools.jackson.databind.ser.std.StdSerializer
_neitherNull, _nonEmpty, _wrapIOFailure, acceptJsonFormatVisitor, acceptJsonFormatVisitorForBinary, createSchemaNode, createSchemaNode, findAnnotatedContentSerializer, findContextualConvertingSerializer, findFormatFeature, findFormatOverrides, findIncludeOverrides, findPropertyFilter, handledType, isDefaultSerializer, serialize, visitArrayFormat, visitArrayFormat, visitFloatFormat, visitIntFormat, visitIntFormat, visitStringFormat, visitStringFormat, wrapAndThrow, wrapAndThrowMethods inherited from class tools.jackson.databind.ValueSerializer
createContextual, getDelegatee, isUnwrappingSerializer, properties, replaceDelegatee, resolve, serializeWithType, unwrappingSerializer, usesObjectId, withFilterId, withFormatOverrides, withIgnoredProperties
-
Field Details
-
_property
Property that contains values handled by this serializer, if known; `null` for root value serializers (ones directly called byObjectMapperandObjectWriter).- Since:
- 3.0
-
_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)
-
-
Constructor Details
-
StdContainerSerializer
-
StdContainerSerializer
-
StdContainerSerializer
-
StdContainerSerializer
-
StdContainerSerializer
-
-
Method Details
-
withValueTypeSerializer
Factory(-like) method that can be used to construct a new container serializer that uses specifiedTypeSerializerfor decorating contained values with additional type information.- Parameters:
vts- Type serializer to use for contained values; can be null, in which case 'this' serializer is returned as is- Returns:
- Serializer instance that uses given type serializer for values if that is possible (or if not, just 'this' serializer)
-
getContentType
Accessor for finding declared (static) element type for type this serializer is used for. -
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 usegetContentType()andSerializationContext.findContentValueSerializer(tools.jackson.databind.JavaType, tools.jackson.databind.BeanProperty). -
isEmpty
Description copied from class:ValueSerializerMethod 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.
- Overrides:
isEmptyin classValueSerializer<T>
-
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 this method is only called by serializer itself; and specifically is not used for non-array/collection types like
MaporMap.Entryinstances. -
_withValueTypeSerializer
Method that needs to be implemented to allow construction of a new serializer object with givenTypeSerializer, used when addition type information is to be embedded. -
_findAndAddDynamic
- Since:
- 3.0
-
_findAndAddDynamic
- Since:
- 3.0
-