Class EnumSerializer
java.lang.Object
edu.internet2.middleware.grouperClientExt.com.fasterxml.jackson.databind.JsonSerializer<T>
edu.internet2.middleware.grouperClientExt.com.fasterxml.jackson.databind.ser.std.StdSerializer<T>
edu.internet2.middleware.grouperClientExt.com.fasterxml.jackson.databind.ser.std.StdScalarSerializer<Enum<?>>
edu.internet2.middleware.grouperClientExt.com.fasterxml.jackson.databind.ser.std.EnumSerializer
- All Implemented Interfaces:
JsonFormatVisitable
,SchemaAware
,ContextualSerializer
,Serializable
Standard serializer used for
Enum
types.
Based on StdScalarSerializer
since the JSON value is
scalar (String).
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class edu.internet2.middleware.grouperClientExt.com.fasterxml.jackson.databind.JsonSerializer
JsonSerializer.None
-
Field Summary
Modifier and TypeFieldDescriptionprotected final Boolean
Flag that is set if we statically know serialization choice between index and textual format (null if it needs to be dynamically checked).protected final EnumValues
This map contains pre-resolved values (since there are ways to customize actual String constants to use) to use as serializations.Fields inherited from class edu.internet2.middleware.grouperClientExt.com.fasterxml.jackson.databind.ser.std.StdSerializer
_handledType
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected static Boolean
_isShapeWrittenUsingIndex
(Class<?> enumClass, JsonFormat.Value format, boolean fromClass, Boolean defaultValue) Helper method called to check whether serialization should be done using index (number) or not.protected final boolean
_serializeAsIndex
(SerializerProvider serializers) void
acceptJsonFormatVisitor
(JsonFormatVisitorWrapper visitor, JavaType typeHint) Default implementation specifies no format.static EnumSerializer
construct
(Class<?> enumClass, SerializationConfig config, BeanDescription beanDesc, JsonFormat.Value format) Factory method used byBasicSerializerFactory
for constructing serializer instance of Enum types.createContextual
(SerializerProvider serializers, BeanProperty property) To support some level of per-property configuration, we will need to make things contextual.getSchema
(SerializerProvider provider, Type typeHint) Default implementation simply claims type is "string"; usually overriden by custom serializers.final void
serialize
(Enum<?> en, JsonGenerator gen, SerializerProvider serializers) Method that can be called to ask implementation to serialize values of type this serializer handles.Methods inherited from class edu.internet2.middleware.grouperClientExt.com.fasterxml.jackson.databind.ser.std.StdScalarSerializer
serializeWithType
Methods inherited from class edu.internet2.middleware.grouperClientExt.com.fasterxml.jackson.databind.ser.std.StdSerializer
_neitherNull, _nonEmpty, createSchemaNode, createSchemaNode, findAnnotatedContentSerializer, findContextualConvertingSerializer, findConvertingContentSerializer, findFormatFeature, findFormatOverrides, findIncludeOverrides, findPropertyFilter, getSchema, handledType, isDefaultSerializer, visitArrayFormat, visitArrayFormat, visitFloatFormat, visitIntFormat, visitIntFormat, visitStringFormat, visitStringFormat, wrapAndThrow, wrapAndThrow
Methods inherited from class edu.internet2.middleware.grouperClientExt.com.fasterxml.jackson.databind.JsonSerializer
getDelegatee, isEmpty, isEmpty, isUnwrappingSerializer, properties, replaceDelegatee, unwrappingSerializer, usesObjectId, withFilterId
-
Field Details
-
_values
This map contains pre-resolved values (since there are ways to customize actual String constants to use) to use as serializations. -
_serializeAsIndex
Flag that is set if we statically know serialization choice between index and textual format (null if it needs to be dynamically checked).- Since:
- 2.1
-
-
Constructor Details
-
EnumSerializer
-
-
Method Details
-
construct
public static EnumSerializer construct(Class<?> enumClass, SerializationConfig config, BeanDescription beanDesc, JsonFormat.Value format) Factory method used byBasicSerializerFactory
for constructing serializer instance of Enum types.- Since:
- 2.1
-
createContextual
public JsonSerializer<?> createContextual(SerializerProvider serializers, BeanProperty property) throws JsonMappingException To support some level of per-property configuration, we will need to make things contextual. We are limited to "textual vs index" choice here, however.- Specified by:
createContextual
in interfaceContextualSerializer
- Parameters:
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)- Returns:
- Serializer to use for serializing values of specified property; may be this instance or a new instance.
- Throws:
JsonMappingException
-
getEnumValues
-
serialize
public final void serialize(Enum<?> en, JsonGenerator gen, SerializerProvider serializers) throws IOException Description copied from class:JsonSerializer
Method that can be called to ask implementation to serialize values of type this serializer handles.- Specified by:
serialize
in classStdSerializer<Enum<?>>
- Parameters:
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.- Throws:
IOException
-
getSchema
Description copied from class:StdSerializer
Default implementation simply claims type is "string"; usually overriden by custom serializers.- Specified by:
getSchema
in interfaceSchemaAware
- Overrides:
getSchema
in classStdScalarSerializer<Enum<?>>
- Parameters:
provider
- The serializer provider.typeHint
- A hint about the type.- Returns:
- Json-schema for this serializer.
-
acceptJsonFormatVisitor
public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException Description copied from class:StdSerializer
Default implementation specifies no format. This behavior is usually overriden by custom serializers.- Specified by:
acceptJsonFormatVisitor
in interfaceJsonFormatVisitable
- Overrides:
acceptJsonFormatVisitor
in classStdScalarSerializer<Enum<?>>
typeHint
- Type of element (entity like property) being visited- Throws:
JsonMappingException
-
_serializeAsIndex
-
_isShapeWrittenUsingIndex
protected static Boolean _isShapeWrittenUsingIndex(Class<?> enumClass, JsonFormat.Value format, boolean fromClass, Boolean defaultValue) Helper method called to check whether serialization should be done using index (number) or not.
-