Interface MessageBodyReader<T>

Type Parameters:
T - The generic type.
All Superinterfaces:
io.micronaut.core.order.Ordered
All Known Subinterfaces:
ChunkedMessageBodyReader<T>, MessageBodyHandler<T>
All Known Implementing Classes:
TextPlainHandler

@Indexed(MessageBodyReader.class) public interface MessageBodyReader<T> extends io.micronaut.core.order.Ordered
An interface that allows reading a message body from the client or the server.

Implementors can defined beans that are annotated with Consumes to restrict the applicable content types.

Since:
4.0.0
See Also:
  • Field Summary

    Fields inherited from interface io.micronaut.core.order.Ordered

    HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
  • Method Summary

    Modifier and Type
    Method
    Description
    default boolean
    isReadable(io.micronaut.core.type.Argument<T> type, MediaType mediaType)
    Is the type readable.
    default T
    read(io.micronaut.core.type.Argument<T> type, MediaType mediaType, io.micronaut.core.type.Headers httpHeaders, io.micronaut.core.io.buffer.ByteBuffer<?> byteBuffer)
    Reads an object from the given byte buffer.
    read(io.micronaut.core.type.Argument<T> type, MediaType mediaType, io.micronaut.core.type.Headers httpHeaders, InputStream inputStream)
    Reads an object from the given byte buffer.

    Methods inherited from interface io.micronaut.core.order.Ordered

    getOrder
  • Method Details

    • isReadable

      default boolean isReadable(@NonNull io.micronaut.core.type.Argument<T> type, @Nullable MediaType mediaType)
      Is the type readable.
      Parameters:
      type - The type
      mediaType - The media type, can be null
      Returns:
      True if is readable
    • read

      @Nullable default T read(@NonNull io.micronaut.core.type.Argument<T> type, @Nullable MediaType mediaType, @NonNull io.micronaut.core.type.Headers httpHeaders, @NonNull io.micronaut.core.io.buffer.ByteBuffer<?> byteBuffer) throws CodecException
      Reads an object from the given byte buffer.
      Parameters:
      type - The type being decoded.
      mediaType - The media type, can be null
      httpHeaders - The HTTP headers
      byteBuffer - The byte buffer
      Returns:
      The read object or null
      Throws:
      CodecException - If an error occurs decoding
    • read

      @Nullable T read(@NonNull io.micronaut.core.type.Argument<T> type, @Nullable MediaType mediaType, @NonNull io.micronaut.core.type.Headers httpHeaders, @NonNull InputStream inputStream) throws CodecException
      Reads an object from the given byte buffer.
      Parameters:
      type - The type being decoded.
      mediaType - The media type, can be null
      httpHeaders - The HTTP headers
      inputStream - The input stream
      Returns:
      The read object or null
      Throws:
      CodecException - If an error occurs decoding