public class TypeConstrainedMappingJackson2HttpMessageConverter extends MappingJackson2HttpMessageConverter
MappingJackson2HttpMessageConverter
to constrain the ability to read and write HTTP message
based on the target type. Useful in case the ObjectMapper
about to be configured has customizations that
shall only be applied to object trees of a certain base type.DEFAULT_CHARSET, objectMapper
logger
Constructor and Description |
---|
TypeConstrainedMappingJackson2HttpMessageConverter(Class<?> type)
Creates a new
TypeConstrainedMappingJackson2HttpMessageConverter for the given type. |
TypeConstrainedMappingJackson2HttpMessageConverter(Class<?> type,
List<MediaType> supportedMediaTypes,
com.fasterxml.jackson.databind.ObjectMapper objectMapper)
Convenience constructor to supply all parameters at once.
|
Modifier and Type | Method and Description |
---|---|
boolean |
canRead(Class<?> clazz,
MediaType mediaType) |
boolean |
canRead(Type type,
Class<?> contextClass,
MediaType mediaType) |
boolean |
canWrite(Class<?> clazz,
MediaType mediaType) |
setJsonPrefix, setPrefixJson, writePrefix
getCharset, getContentLength, getDefaultContentType, getJavaType, getJsonEncoding, getObjectMapper, logWarningIfNecessary, read, readInternal, setObjectMapper, setPrettyPrint, writeInternal, writeSuffix
canWrite, supports, write, writeInternal
addDefaultHeaders, canRead, canWrite, getDefaultCharset, getSupportedMediaTypes, read, setDefaultCharset, setSupportedMediaTypes, write
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getSupportedMediaTypes, read, write
public TypeConstrainedMappingJackson2HttpMessageConverter(Class<?> type)
TypeConstrainedMappingJackson2HttpMessageConverter
for the given type.type
- must not be null.public TypeConstrainedMappingJackson2HttpMessageConverter(Class<?> type, List<MediaType> supportedMediaTypes, com.fasterxml.jackson.databind.ObjectMapper objectMapper)
type
- supportedMediaTypes
- objectMapper
- public boolean canRead(Class<?> clazz, @Nullable MediaType mediaType)
canRead
in interface HttpMessageConverter<Object>
canRead
in class AbstractJackson2HttpMessageConverter
public boolean canRead(Type type, @Nullable Class<?> contextClass, @Nullable MediaType mediaType)
canRead
in interface GenericHttpMessageConverter<Object>
canRead
in class AbstractJackson2HttpMessageConverter
public boolean canWrite(Class<?> clazz, @Nullable MediaType mediaType)
canWrite
in interface HttpMessageConverter<Object>
canWrite
in class AbstractJackson2HttpMessageConverter
Copyright © 2011–2021 Pivotal, Inc.. All rights reserved.