org.springframework.core.codec

## Class AbstractDecoder<T>

- java.lang.Object
- - org.springframework.core.codec.AbstractDecoder<T>

- Type Parameters:
    `T` - the element type
  All Implemented Interfaces:
    Decoder<T>
  Direct Known Subclasses:
    AbstractDataBufferDecoder, Jaxb2XmlDecoder, KotlinSerializationJsonDecoder, XmlEventDecoder

      public abstract class AbstractDecoder<T>
      extends Object
      implements Decoder<T>

  Abstract base class for `Decoder` implementations.
  Since:
    5.0
  Author:
    Sebastien Deleuze, Arjen Poutsma

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected Log` | `logger`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `AbstractDecoder(MimeType... supportedMimeTypes)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `canDecode(ResolvableType elementType, MimeType mimeType)` Whether the decoder supports the given target element type and the MIME type of the source stream.
    `reactor.core.publisher.Mono<T>` | `decodeToMono(Publisher<DataBuffer> inputStream, ResolvableType elementType, MimeType mimeType, Map<String,Object> hints)` Decode a `DataBuffer` input stream into a Mono of `T`.
    `List<MimeType>` | `getDecodableMimeTypes()` Return the list of MIME types supported by this Decoder.
    `Log` | `getLogger()` Return the currently configured Logger.
    `void` | `setLogger(Log logger)` Set an alternative logger to use than the one based on the class name.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface org.springframework.core.codec.Decoder

      `decode, decode, getDecodableMimeTypes`

- - ### Field Detail

    - #### logger

          protected Log logger

  - ### Constructor Detail

    - #### AbstractDecoder

          protected AbstractDecoder(MimeType... supportedMimeTypes)

  - ### Method Detail

    - #### setLogger

          public void setLogger(Log logger)

      Set an alternative logger to use than the one based on the class name.
      Parameters:
        `logger` - the logger to use
      Since:
        5.1

    - #### getLogger

          public Log getLogger()

      Return the currently configured Logger.
      Since:
        5.1

    - #### getDecodableMimeTypes

          public List<MimeType> getDecodableMimeTypes()

      Description copied from interface: `Decoder`
      Return the list of MIME types supported by this Decoder. The list may not apply to every possible target element type and calls to this method should typically be guarded via `canDecode(elementType, null)`. The list may also exclude MIME types supported only for a specific element type. Alternatively, use `Decoder.getDecodableMimeTypes(ResolvableType)` for a more precise list.
      Specified by:
        `getDecodableMimeTypes` in interface `Decoder<T>`
      Returns:
        the list of supported MIME types

    - #### canDecode

          public boolean canDecode(ResolvableType elementType,
                                   @Nullable
                                   MimeType mimeType)

      Description copied from interface: `Decoder`
      Whether the decoder supports the given target element type and the MIME type of the source stream.
      Specified by:
        `canDecode` in interface `Decoder<T>`
      Parameters:
        `elementType` - the target element type for the output stream
        `mimeType` - the mime type associated with the stream to decode (can be `null` if not specified)
      Returns:
        `true` if supported, `false` otherwise

    - #### decodeToMono

          public reactor.core.publisher.Mono<T> decodeToMono(Publisher<DataBuffer> inputStream,
                                                             ResolvableType elementType,
                                                             @Nullable
                                                             MimeType mimeType,
                                                             @Nullable
                                                             Map<String,Object> hints)

      Description copied from interface: `Decoder`
      Decode a `DataBuffer` input stream into a Mono of `T`.
      Specified by:
        `decodeToMono` in interface `Decoder<T>`
      Parameters:
        `inputStream` - the `DataBuffer` input stream to decode
        `elementType` - the expected type of elements in the output stream; this type must have been previously passed to the `Decoder.canDecode(org.springframework.core.ResolvableType, org.springframework.util.MimeType)` method and it must have returned `true`.
        `mimeType` - the MIME type associated with the input stream (optional)
        `hints` - additional information about how to do decode
      Returns:
        the output stream with the decoded element