Search in sources :

Example 6 with SerializationConfig

use of com.fasterxml.jackson.databind.SerializationConfig in project jackson-databind by FasterXML.

the class EnumValuesTest method testConstructFromName.

@SuppressWarnings("unchecked")
public void testConstructFromName() {
    SerializationConfig cfg = MAPPER.getSerializationConfig().without(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
    Class<Enum<?>> enumClass = (Class<Enum<?>>) (Class<?>) ABC.class;
    EnumValues values = EnumValues.construct(cfg, enumClass);
    assertEquals("A", values.serializedValueFor(ABC.A).toString());
    assertEquals("B", values.serializedValueFor(ABC.B).toString());
    assertEquals("C", values.serializedValueFor(ABC.C).toString());
    assertEquals(3, values.values().size());
    assertEquals(3, values.internalMap().size());
}
Also used : SerializationConfig(com.fasterxml.jackson.databind.SerializationConfig)

Aggregations

SerializationConfig (com.fasterxml.jackson.databind.SerializationConfig)6 JavaType (com.fasterxml.jackson.databind.JavaType)3 ObjectWriter (com.fasterxml.jackson.databind.ObjectWriter)2 JsonSubTypes (com.fasterxml.jackson.annotation.JsonSubTypes)1 JsonEncoding (com.fasterxml.jackson.core.JsonEncoding)1 JsonGenerator (com.fasterxml.jackson.core.JsonGenerator)1 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 BeanDescription (com.fasterxml.jackson.databind.BeanDescription)1 DeserializationConfig (com.fasterxml.jackson.databind.DeserializationConfig)1 SerializerProvider (com.fasterxml.jackson.databind.SerializerProvider)1 BeanPropertyDefinition (com.fasterxml.jackson.databind.introspect.BeanPropertyDefinition)1 JsonObjectFormatVisitor (com.fasterxml.jackson.databind.jsonFormatVisitors.JsonObjectFormatVisitor)1 FilterProvider (com.fasterxml.jackson.databind.ser.FilterProvider)1 TypeFactory (com.fasterxml.jackson.databind.type.TypeFactory)1 IOException (java.io.IOException)1 OutputStream (java.io.OutputStream)1 CodecException (org.springframework.core.codec.CodecException)1 DataBuffer (org.springframework.core.io.buffer.DataBuffer)1 MediaType (org.springframework.http.MediaType)1 HttpMessageNotWritableException (org.springframework.http.converter.HttpMessageNotWritableException)1