org.springframework.messaging.handler.annotation.support

## Class MessageMethodArgumentResolver

- java.lang.Object
- - org.springframework.messaging.handler.annotation.support.MessageMethodArgumentResolver

All Implemented Interfaces:
  HandlerMethodArgumentResolver

    public class MessageMethodArgumentResolver
    extends Object
    implements HandlerMethodArgumentResolver

`HandlerMethodArgumentResolver` for `Message` method arguments. Validates that the generic type of the payload matches to the message value or otherwise applies `MessageConverter` to convert to the expected payload type.

Since:
  4.0
Author:
  Rossen Stoyanchev, Stephane Nicoll, Juergen Hoeller

### Constructor Summary

Constructors
Constructor and Description
`MessageMethodArgumentResolver()` Create a default resolver instance without message conversion.
`MessageMethodArgumentResolver(MessageConverter converter)` Create a resolver instance with the given `MessageConverter`.

### Method Summary

All Methods Instance Methods Concrete Methods
`protected Class<?>` `getPayloadType(org.springframework.core.MethodParameter parameter, Message<?> message)` Resolve the target class to convert the payload to.
`protected boolean` `isEmptyPayload(Object payload)` Check if the given `payload` is empty.
`Object` `resolveArgument(org.springframework.core.MethodParameter parameter, Message<?> message)` Resolves a method parameter into an argument value from a given message.
`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`

### Constructor Detail

#### MessageMethodArgumentResolver

    public MessageMethodArgumentResolver()

Create a default resolver instance without message conversion.

#### MessageMethodArgumentResolver

    public MessageMethodArgumentResolver(@Nullable
                                         MessageConverter converter)

Create a resolver instance with the given `MessageConverter`.

Parameters:
  `converter` - the MessageConverter to use (may be `null`)
Since:
  4.3

### Method Detail

#### 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 Object resolveArgument(org.springframework.core.MethodParameter parameter,
                                  Message<?> message)
                           throws Exception

Description copied from interface: `HandlerMethodArgumentResolver`
Resolves a method parameter into an argument value from a given message.

Specified by:
  `resolveArgument` in interface `HandlerMethodArgumentResolver`
Parameters:
  `parameter` - the method parameter to resolve. This parameter must have previously been passed to `HandlerMethodArgumentResolver.supportsParameter(org.springframework.core.MethodParameter)` which must have returned `true`.
  `message` - the currently processed message
Returns:
  the resolved argument value, or `null`
Throws:
  `Exception` - in case of errors with the preparation of argument values

#### getPayloadType

    protected Class<?> getPayloadType(org.springframework.core.MethodParameter parameter,
                                      Message<?> message)

Resolve the target class to convert the payload to.

By default this is the generic type declared in the `Message` method parameter but that can be overridden to select a more specific target type after also taking into account the "Content-Type", e.g. return `String` if target type is `Object` and `"Content-Type:text/**"`.

Parameters:
  `parameter` - the target method parameter
  `message` - the message being processed
Returns:
  the target type to use
Since:
  5.2

#### isEmptyPayload

    protected boolean isEmptyPayload(@Nullable
                                     Object payload)

Check if the given `payload` is empty.

Parameters:
  `payload` - the payload to check (can be `null`)