public class AbstractJackson2Codec extends Object
| Modifier and Type | Field and Description |
|---|---|
protected static List<org.springframework.util.MimeType> |
JSON_MIME_TYPES |
static String |
JSON_VIEW_HINT
Hint key to use with a
Class value specifying the JSON View to use to serialize
or deserialize an object. |
protected ObjectMapper |
mapper |
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractJackson2Codec(ObjectMapper mapper)
Create a new Jackson codec for the given mapper.
|
| Modifier and Type | Method and Description |
|---|---|
protected JavaType |
getJavaType(Type type,
Class<?> contextClass)
Return the Jackson
JavaType for the specified type and context class. |
public static final String JSON_VIEW_HINT
Class value specifying the JSON View to use to serialize
or deserialize an object.protected static final List<org.springframework.util.MimeType> JSON_MIME_TYPES
protected final ObjectMapper mapper
protected AbstractJackson2Codec(ObjectMapper mapper)
mapper - the Jackson ObjectMapper to useprotected JavaType getJavaType(Type type, Class<?> contextClass)
JavaType for the specified type and context class.
The default implementation returns typeFactory.constructType(type, contextClass),
but this can be overridden in subclasses, to allow for custom generic collection handling.
For instance:
protected JavaType getJavaType(Type type) {
if (type instanceof Class && List.class.isAssignableFrom((Class)type)) {
return TypeFactory.collectionType(ArrayList.class, MyBean.class);
} else {
return super.getJavaType(type);
}
}
type - the generic type to return the Jackson JavaType forcontextClass - a context class for the target type, for example a class
in which the target type appears in a method signature (can be null)