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.
|
serializeWithType
getSchema, handledType, wrapAndThrow, wrapAndThrow
getDelegatee, isEmpty, isEmpty, isUnwrappingSerializer, properties, replaceDelegatee, unwrappingSerializer, usesObjectId, withFilterId
public 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 ContextualSerializer
serializers
- 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)JsonMappingException
public EnumValues getEnumValues()
public final void serialize(java.lang.Enum<?> en, JsonGenerator gen, SerializerProvider serializers) throws java.io.IOException
JsonSerializer
serialize
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.IOException
public JsonNode getSchema(SerializerProvider provider, java.lang.reflect.Type typeHint)
StdSerializer
getSchema
in interface SchemaAware
getSchema
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
StdSerializer
acceptJsonFormatVisitor
in interface JsonFormatVisitable
acceptJsonFormatVisitor
in class StdScalarSerializer<java.lang.Enum<?>>
typeHint
- Type of element (entity like property) being visitedJsonMappingException
Copyright © 2010 - 2020 Adobe. All Rights Reserved