com.fasterxml.jackson.databind.ser.std

Class EnumSerializer

    • Field Detail

      • _values

        protected final EnumValues _values
        This map contains pre-resolved values (since there are ways to customize actual String constants to use) to use as serializations.
      • _serializeAsIndex

        protected final Boolean _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
    • Method Detail

      • createContextual

        public JsonSerializer<?> createContextual(SerializerProvider prov,
                                         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 interface ContextualSerializer
        Parameters:
        prov - Serializer provider to use for accessing config, other serializers
        property - 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 can not 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

        public EnumValues getEnumValues()
      • serialize

        public final void serialize(Enum<?> en,
                     com.fasterxml.jackson.core.JsonGenerator jgen,
                     SerializerProvider provider)
                             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 class StdSerializer<Enum<?>>
        Parameters:
        en - Value to serialize; can not be null.
        jgen - Generator used to output resulting Json content
        provider - Provider that can be used to get serializers for serializing Objects value contains, if any.
        Throws:
        IOException
      • _serializeAsIndex

        protected final boolean _serializeAsIndex(SerializerProvider provider)
      • _isShapeWrittenUsingIndex

        protected static Boolean _isShapeWrittenUsingIndex(Class<?> enumClass,
                                        com.fasterxml.jackson.annotation.JsonFormat.Value format,
                                        boolean fromClass)
        Helper method called to check whether

Copyright © 2014 FasterXML. All Rights Reserved.