Class Jackson2CodecSupport

java.lang.Object
org.springframework.http.codec.json.Jackson2CodecSupport
Direct Known Subclasses:
AbstractJackson2Decoder, AbstractJackson2Encoder

@Deprecated(since="7.0", forRemoval=true) public abstract class Jackson2CodecSupport extends Object
Deprecated, for removal: This API element is subject to removal in a future version.
since 7.0 in favor of JacksonCodecSupport
Base class providing support methods for Jackson 2.x encoding and decoding.
Since:
5.0
Author:
Sebastien Deleuze, Rossen Stoyanchev
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    Deprecated, for removal: This API element is subject to removal in a future version.
    The key for the hint to specify a "JSON View" for encoding or decoding with the value expected to be a Class.
    protected final org.apache.commons.logging.Log
    Deprecated, for removal: This API element is subject to removal in a future version.
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Jackson2CodecSupport(com.fasterxml.jackson.databind.ObjectMapper objectMapper, MimeType... mimeTypes)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Constructor with a Jackson ObjectMapper to use.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected abstract <A extends Annotation>
    @Nullable A
    getAnnotation(MethodParameter parameter, Class<A> annotType)
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    protected Map<String,Object>
    getHints(ResolvableType resolvableType)
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    protected com.fasterxml.jackson.databind.JavaType
    getJavaType(Type type, @Nullable Class<?> contextClass)
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    protected List<MimeType>
    Deprecated, for removal: This API element is subject to removal in a future version.
    Return the supported media type(s) for ProblemDetail.
    protected List<MimeType>
    Deprecated, for removal: This API element is subject to removal in a future version.
    Subclasses should expose this as "decodable" or "encodable" mime types.
    protected List<MimeType>
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    com.fasterxml.jackson.databind.ObjectMapper
    Deprecated, for removal: This API element is subject to removal in a future version.
    Return the configured default ObjectMapper.
    protected Map<Class<?>, Map<MimeType, com.fasterxml.jackson.databind.ObjectMapper>>
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    @Nullable Map<MimeType, com.fasterxml.jackson.databind.ObjectMapper>
    Deprecated, for removal: This API element is subject to removal in a future version.
    Return ObjectMapper registrations for the given class, if any.
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    protected void
    Deprecated, for removal: This API element is subject to removal in a future version.
    Determine whether to log the given exception coming from a ObjectMapper.canDeserialize(com.fasterxml.jackson.databind.JavaType) / ObjectMapper.canSerialize(java.lang.Class<?>) check.
    void
    registerObjectMappersForType(Class<?> clazz, Consumer<Map<MimeType, com.fasterxml.jackson.databind.ObjectMapper>> registrar)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Configure the ObjectMapper instances to use for the given Class.
    protected @Nullable com.fasterxml.jackson.databind.ObjectMapper
    selectObjectMapper(ResolvableType targetType, @Nullable MimeType targetMimeType)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Select an ObjectMapper to use, either the main ObjectMapper or another if the handling for the given Class has been customized through registerObjectMappersForType(Class, Consumer).
    void
    setObjectMapper(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Configure the default ObjectMapper instance to use.
    protected boolean
    Deprecated, for removal: This API element is subject to removal in a future version.
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • JSON_VIEW_HINT

      public static final String JSON_VIEW_HINT
      Deprecated, for removal: This API element is subject to removal in a future version.
      The key for the hint to specify a "JSON View" for encoding or decoding with the value expected to be a Class.
      See Also:
    • logger

      protected final org.apache.commons.logging.Log logger
      Deprecated, for removal: This API element is subject to removal in a future version.
  • Constructor Details

    • Jackson2CodecSupport

      protected Jackson2CodecSupport(com.fasterxml.jackson.databind.ObjectMapper objectMapper, MimeType... mimeTypes)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Constructor with a Jackson ObjectMapper to use.
  • Method Details

    • setObjectMapper

      public void setObjectMapper(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Configure the default ObjectMapper instance to use.
      Parameters:
      objectMapper - the ObjectMapper instance
      Since:
      5.3.4
    • getObjectMapper

      public com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Return the configured default ObjectMapper.
    • registerObjectMappersForType

      public void registerObjectMappersForType(Class<?> clazz, Consumer<Map<MimeType, com.fasterxml.jackson.databind.ObjectMapper>> registrar)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Configure the ObjectMapper instances to use for the given Class. This is useful when you want to deviate from the default ObjectMapper or have the ObjectMapper vary by MediaType.

      Note: Use of this method effectively turns off use of the default ObjectMapper and supported MimeTypes for the given class. Therefore it is important for the mappings configured here to include every MediaType that must be supported for the given class.

      Parameters:
      clazz - the type of Object to register ObjectMapper instances for
      registrar - a consumer to populate or otherwise update the MediaType-to-ObjectMapper associations for the given Class
      Since:
      5.3.4
    • getObjectMappersForType

      public @Nullable Map<MimeType, com.fasterxml.jackson.databind.ObjectMapper> getObjectMappersForType(Class<?> clazz)
      Deprecated, for removal: This API element is subject to removal in a future version.
      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.
      Since:
      5.3.4
    • getObjectMapperRegistrations

      protected Map<Class<?>, Map<MimeType, com.fasterxml.jackson.databind.ObjectMapper>> getObjectMapperRegistrations()
      Deprecated, for removal: This API element is subject to removal in a future version.
    • getMimeTypes

      protected List<MimeType> getMimeTypes()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Subclasses should expose this as "decodable" or "encodable" mime types.
    • getMimeTypes

      protected List<MimeType> getMimeTypes(ResolvableType elementType)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • getMediaTypesForProblemDetail

      protected List<MimeType> getMediaTypesForProblemDetail()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Return the supported media type(s) for ProblemDetail. By default, an empty list, unless overridden in subclasses.
      Since:
      6.0.5
    • supportsMimeType

      protected boolean supportsMimeType(@Nullable MimeType mimeType)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • logWarningIfNecessary

      protected void logWarningIfNecessary(Type type, @Nullable Throwable cause)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Determine whether to log the given exception coming from a ObjectMapper.canDeserialize(com.fasterxml.jackson.databind.JavaType) / ObjectMapper.canSerialize(java.lang.Class<?>) check.
      Parameters:
      type - the class that Jackson tested for (de-)serializability
      cause - the Jackson-thrown exception to evaluate (typically a JsonMappingException)
      Since:
      5.3.1
    • getJavaType

      protected com.fasterxml.jackson.databind.JavaType getJavaType(Type type, @Nullable Class<?> contextClass)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • getHints

      protected Map<String,Object> getHints(ResolvableType resolvableType)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • getParameter

      protected @Nullable MethodParameter getParameter(ResolvableType type)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • getAnnotation

      protected abstract <A extends Annotation> @Nullable A getAnnotation(MethodParameter parameter, Class<A> annotType)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • selectObjectMapper

      protected @Nullable com.fasterxml.jackson.databind.ObjectMapper selectObjectMapper(ResolvableType targetType, @Nullable MimeType targetMimeType)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Select an ObjectMapper to use, either the main ObjectMapper or another if the handling for the given Class has been customized through registerObjectMappersForType(Class, Consumer).
      Since:
      5.3.4