public class EnumSerializer extends StdScalarSerializer<java.lang.Enum<?>> implements ContextualSerializer
Enum types.
Based on StdScalarSerializer since the JSON value is
scalar (String).
JsonSerializer.None| Constructor and Description |
|---|
EnumSerializer(EnumValues v,
java.lang.Boolean serializeAsIndex) |
| Modifier and Type | Method and Description |
|---|---|
void |
acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor,
JavaType typeHint)
Default implementation specifies no format.
|
static EnumSerializer |
construct(java.lang.Class<?> enumClass,
SerializationConfig config,
BeanDescription beanDesc,
JsonFormat.Value format)
Factory method used by
BasicSerializerFactory
for constructing serializer instance of Enum types. |
JsonSerializer<?> |
createContextual(SerializerProvider serializers,
BeanProperty property)
To support some level of per-property configuration, we will need
to make things contextual.
|
EnumValues |
getEnumValues() |
JsonNode |
getSchema(SerializerProvider provider,
java.lang.reflect.Type typeHint)
Default implementation simply claims type is "string"; usually
overriden by custom serializers.
|
void |
serialize(java.lang.Enum<?> en,
JsonGenerator gen,
SerializerProvider serializers)
Method that can be called to ask implementation to serialize
values of type this serializer handles.
|
serializeWithTypegetSchema, handledType, wrapAndThrow, wrapAndThrowgetDelegatee, isEmpty, isEmpty, isUnwrappingSerializer, properties, replaceDelegatee, unwrappingSerializer, usesObjectId, withFilterIdpublic EnumSerializer(EnumValues v, java.lang.Boolean serializeAsIndex)
public static EnumSerializer construct(java.lang.Class<?> enumClass, SerializationConfig config, BeanDescription beanDesc, JsonFormat.Value format)
BasicSerializerFactory
for constructing serializer instance of Enum types.public JsonSerializer<?> createContextual(SerializerProvider serializers, BeanProperty property) throws JsonMappingException
createContextual in interface ContextualSerializerserializers - Serializer provider to use for accessing config, other serializersproperty - Method or field that represents the property
(and is used to access value to serialize).
Should be available; but there may be cases where caller cannot provide it and
null is passed instead (in which case impls usually pass 'this' serializer as is)JsonMappingExceptionpublic EnumValues getEnumValues()
public final void serialize(java.lang.Enum<?> en,
JsonGenerator gen,
SerializerProvider serializers)
throws java.io.IOException
JsonSerializerserialize in class StdSerializer<java.lang.Enum<?>>en - Value to serialize; can not be null.gen - Generator used to output resulting Json contentserializers - Provider that can be used to get serializers for
serializing Objects value contains, if any.java.io.IOExceptionpublic JsonNode getSchema(SerializerProvider provider, java.lang.reflect.Type typeHint)
StdSerializergetSchema in interface SchemaAwaregetSchema in class StdScalarSerializer<java.lang.Enum<?>>provider - The serializer provider.typeHint - A hint about the type.public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException
StdSerializeracceptJsonFormatVisitor in interface JsonFormatVisitableacceptJsonFormatVisitor in class StdScalarSerializer<java.lang.Enum<?>>typeHint - Type of element (entity like property) being visitedJsonMappingExceptionCopyright © 2010 - 2023 Adobe. All Rights Reserved