Module tools.jackson.databind
Package tools.jackson.databind.ser.jdk
Class StringCollectionSerializer
java.lang.Object
tools.jackson.databind.ValueSerializer<T>
tools.jackson.databind.ser.std.StdSerializer<T>
tools.jackson.databind.ser.jdk.StaticListSerializerBase<Collection<String>>
tools.jackson.databind.ser.jdk.StringCollectionSerializer
- All Implemented Interfaces:
JsonFormatVisitable
Efficient implement for serializing
Collections that contain Strings.
The only complexity is due to possibility that serializer for String
may be override; because of this, logic is needed to ensure that the default
serializer is in use to use fastest mode, or if not, to defer to custom
String serializer.-
Nested Class Summary
Nested classes/interfaces inherited from class tools.jackson.databind.ValueSerializer
ValueSerializer.None -
Field Summary
FieldsFields inherited from class tools.jackson.databind.ser.jdk.StaticListSerializerBase
_unwrapSingleFields inherited from class tools.jackson.databind.ser.std.StdSerializer
_handledType -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedprotectedStringCollectionSerializer(StringCollectionSerializer src, Boolean unwrapSingle) -
Method Summary
Modifier and TypeMethodDescription_withResolved(BeanProperty prop, Boolean unwrapSingle) protected voidprotected JsonNodevoidserialize(Collection<String> value, JsonGenerator g, SerializationContext provider) Method that can be called to ask implementation to serialize values of type this serializer handles.voidserializeWithType(Collection<String> value, JsonGenerator g, SerializationContext ctxt, TypeSerializer typeSer) 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.Methods inherited from class tools.jackson.databind.ser.jdk.StaticListSerializerBase
acceptJsonFormatVisitor, createContextual, isEmptyMethods inherited from class tools.jackson.databind.ser.std.StdSerializer
_neitherNull, _nonEmpty, _wrapIOFailure, acceptJsonFormatVisitorForBinary, createSchemaNode, createSchemaNode, findAnnotatedContentSerializer, findContextualConvertingSerializer, findFormatFeature, findFormatOverrides, findIncludeOverrides, findPropertyFilter, handledType, isDefaultSerializer, visitArrayFormat, visitArrayFormat, visitFloatFormat, visitIntFormat, visitIntFormat, visitStringFormat, visitStringFormat, wrapAndThrow, wrapAndThrowMethods inherited from class tools.jackson.databind.ValueSerializer
getDelegatee, isUnwrappingSerializer, properties, replaceDelegatee, resolve, unwrappingSerializer, usesObjectId, withFilterId, withFormatOverrides, withIgnoredProperties
-
Field Details
-
instance
-
-
Constructor Details
-
StringCollectionSerializer
protected StringCollectionSerializer() -
StringCollectionSerializer
-
-
Method Details
-
_withResolved
- Specified by:
_withResolvedin classStaticListSerializerBase<Collection<String>>
-
contentSchema
- Specified by:
contentSchemain classStaticListSerializerBase<Collection<String>>
-
acceptContentVisitor
- Specified by:
acceptContentVisitorin classStaticListSerializerBase<Collection<String>>
-
serialize
public void serialize(Collection<String> value, JsonGenerator g, SerializationContext provider) throws JacksonException Description copied from class:ValueSerializerMethod that can be called to ask implementation to serialize values of type this serializer handles.- Specified by:
serializein classStdSerializer<Collection<String>>- Parameters:
value- Value to serialize; can not be null.g- Generator used to output resulting Json contentprovider- Context that can be used to get serializers for serializing Objects value contains, if any.- Throws:
JacksonException
-
serializeWithType
public void serializeWithType(Collection<String> value, JsonGenerator g, SerializationContext ctxt, TypeSerializer typeSer) throws JacksonException Description copied from class:ValueSerializerMethod 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
UnsupportedOperationExceptionto 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, asSTART-ARRAY/END-ARRAYandSTART-OBJECT/END-OBJECTpairs need to be properly handled with respect to serializing of contents.- Specified by:
serializeWithTypein classStaticListSerializerBase<Collection<String>>- Parameters:
value- Value to serialize; can not be null.g- Generator used to output resulting Json contentctxt- Context that can be used to get serializers for serializing Objects value contains, if any.typeSer- Type serializer to use for including type information- Throws:
JacksonException
-