org.springframework.messaging.handler.annotation.reactive

## Class PayloadMethodArgumentResolver

- java.lang.Object
- - org.springframework.messaging.handler.annotation.reactive.PayloadMethodArgumentResolver

All Implemented Interfaces:
  HandlerMethodArgumentResolver

    public class PayloadMethodArgumentResolver
    extends Object
    implements HandlerMethodArgumentResolver

A resolver to extract and decode the payload of a message using a `Decoder`, where the payload is expected to be a `Publisher` of `DataBuffer`.

Validation is applied if the method argument is annotated with `@javax.validation.Valid` or `Validated`. Validation failure results in an `MethodArgumentNotValidException`.

This resolver should be ordered last if `useDefaultResolution` is set to `true` since in that case it supports all types and does not require the presence of `Payload`.

Since:
  5.2
Author:
  Rossen Stoyanchev

### Field Summary

Fields
`protected Log` `logger`

### Constructor Summary

Constructors
Constructor and Description
`PayloadMethodArgumentResolver(List<? extends org.springframework.core.codec.Decoder<?>> decoders, org.springframework.validation.Validator validator, org.springframework.core.ReactiveAdapterRegistry registry, boolean useDefaultResolution)`

### Method Summary

All Methods Instance Methods Concrete Methods
`org.springframework.core.ReactiveAdapterRegistry` `getAdapterRegistry()` Return the configured `ReactiveAdapterRegistry`.
`List<org.springframework.core.codec.Decoder<?>>` `getDecoders()` Return a read-only list of the configured decoders.
`protected org.springframework.util.MimeType` `getMimeType(Message<?> message)` Return the mime type for the content.
`org.springframework.validation.Validator` `getValidator()` Return the configured validator, if any.
`boolean` `isUseDefaultResolution()` Whether this resolver is configured to use default resolution, i.e.
`reactor.core.publisher.Mono<Object>` `resolveArgument(org.springframework.core.MethodParameter parameter, Message<?> message)` Decode the content of the given message payload through a compatible `Decoder`.
`boolean` `supportsParameter(org.springframework.core.MethodParameter parameter)` Whether the given method parameter is supported by this resolver.

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

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

### Field Detail

#### logger

    protected final Log logger

### Constructor Detail

#### PayloadMethodArgumentResolver

    public PayloadMethodArgumentResolver(List<? extends org.springframework.core.codec.Decoder<?>> decoders,
                                         @Nullable
                                         org.springframework.validation.Validator validator,
                                         @Nullable
                                         org.springframework.core.ReactiveAdapterRegistry registry,
                                         boolean useDefaultResolution)

### Method Detail

#### getDecoders

    public List<org.springframework.core.codec.Decoder<?>> getDecoders()

Return a read-only list of the configured decoders.

#### getValidator

    @Nullable
    public org.springframework.validation.Validator getValidator()

Return the configured validator, if any.

#### getAdapterRegistry

    public org.springframework.core.ReactiveAdapterRegistry getAdapterRegistry()

Return the configured `ReactiveAdapterRegistry`.

#### isUseDefaultResolution

    public boolean isUseDefaultResolution()

Whether this resolver is configured to use default resolution, i.e. works for any argument type regardless of whether `@Payload` is present or not.

#### supportsParameter

    public boolean supportsParameter(org.springframework.core.MethodParameter parameter)

Description copied from interface: `HandlerMethodArgumentResolver`
Whether the given method parameter is supported by this resolver.

Specified by:
  `supportsParameter` in interface `HandlerMethodArgumentResolver`
Parameters:
  `parameter` - the method parameter to check
Returns:
  `true` if this resolver supports the supplied parameter; `false` otherwise

#### resolveArgument

    public final reactor.core.publisher.Mono<Object> resolveArgument(org.springframework.core.MethodParameter parameter,
                                                                     Message<?> message)

Decode the content of the given message payload through a compatible `Decoder`.

Validation is applied if the method argument is annotated with `@javax.validation.Valid` or `Validated`. Validation failure results in an `MethodArgumentNotValidException`.

Specified by:
  `resolveArgument` in interface `HandlerMethodArgumentResolver`
Parameters:
  `parameter` - the target method argument that we are decoding to
  `message` - the message from which the content was extracted
Returns:
  a Mono with the result of argument resolution
See Also:
  `extractContent(MethodParameter, Message)`, `getMimeType(Message)`

#### getMimeType

    @Nullable
    protected org.springframework.util.MimeType getMimeType(Message<?> message)

Return the mime type for the content. By default this method checks the `MessageHeaders.CONTENT_TYPE` header expecting to find a `MimeType` value or a String to parse to a `MimeType`.

Parameters:
  `message` - the input message