Class JacksonCodecSupport<T extends tools.jackson.databind.ObjectMapper>
java.lang.Object
org.springframework.http.codec.JacksonCodecSupport<T>
- Type Parameters:
T- the type ofObjectMapper
- Direct Known Subclasses:
AbstractJacksonDecoder, AbstractJacksonEncoder
public abstract class JacksonCodecSupport<T extends tools.jackson.databind.ObjectMapper>
extends Object
Base class providing support methods for Jackson 3.x encoding and decoding.
- Since:
- 7.0
- Author:
- Sebastien Deleuze
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedJacksonCodecSupport(tools.jackson.databind.cfg.MapperBuilder<T, ?> builder, MimeType... mimeTypes) Construct a new instance with the providedbuildercustomized with theJacksonModules found byMapperBuilder.findModules(ClassLoader)andMimeTypes.protectedJacksonCodecSupport(T mapper, MimeType... mimeTypes) Construct a new instance with the providedObjectMappercustomized with theJacksonModules found byMapperBuilder.findModules(ClassLoader)andMimeTypes. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract <A extends Annotation>
@Nullable AgetAnnotation(MethodParameter parameter, Class<A> annotType) getHints(ResolvableType resolvableType) protected tools.jackson.databind.JavaTypegetJavaType(Type type, @Nullable Class<?> contextClass) Return theconfigureddefault mapper.getMappersForType(Class<?> clazz) Return ObjectMapper registrations for the given class, if any.Return the supported media type(s) forProblemDetail.Subclasses should expose this as "decodable" or "encodable" mime types.getMimeTypes(ResolvableType elementType) protected @Nullable MethodParametergetParameter(ResolvableType type) voidConfigure theObjectMapperinstances to use for the givenClass.selectMapper(ResolvableType targetType, @Nullable MimeType targetMimeType) Select an ObjectMapper to use, either the main ObjectMapper or another if the handling for the given Class has been customized throughregisterMappersForType(Class, Consumer).protected booleansupportsMimeType(@Nullable MimeType mimeType)
-
Field Details
-
JSON_VIEW_HINT
-
FILTER_PROVIDER_HINT
The key for the hint to specify aFilterProvider. -
logger
protected final org.apache.commons.logging.Log logger -
mapperRegistrations
-
-
Constructor Details
-
JacksonCodecSupport
-
JacksonCodecSupport
-
-
Method Details
-
getMapper
Return theconfigureddefault mapper. -
registerMappersForType
Configure theObjectMapperinstances to use for the givenClass. This is useful when you want to deviate from thedefaultObjectMapper or have theObjectMappervary byMediaType.Note: Use of this method effectively turns off use of the default
ObjectMapperand supportedMimeTypesfor the given class. Therefore it is important for the mappings configured here toincludeevery MediaType that must be supported for the given class.- Parameters:
clazz- the type of Object to register ObjectMapper instances forregistrar- a consumer to populate or otherwise update the MediaType-to-ObjectMapper associations for the given Class
-
getMappersForType
Return ObjectMapper registrations for the given class, if any.- Parameters:
clazz- the class to look up for registrations for- Returns:
- a map with registered MediaType-to-ObjectMapper registrations, or empty if in case of no registrations for the given class.
-
getMapperRegistrations
-
getMimeTypes
-
getMimeTypes
-
getMediaTypesForProblemDetail
Return the supported media type(s) forProblemDetail. By default, an empty list, unless overridden in subclasses. -
supportsMimeType
-
getJavaType
-
getHints
-
getParameter
-
getAnnotation
protected abstract <A extends Annotation> @Nullable A getAnnotation(MethodParameter parameter, Class<A> annotType) -
selectMapper
Select an ObjectMapper to use, either the main ObjectMapper or another if the handling for the given Class has been customized throughregisterMappersForType(Class, Consumer).
-