org.springframework.messaging.handler.annotation.support

## Class PayloadArgumentResolver

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

- All Implemented Interfaces:
    HandlerMethodArgumentResolver

      public class PayloadArgumentResolver
      extends Object
      implements HandlerMethodArgumentResolver

  A resolver to extract and convert the payload of a message using a `MessageConverter`. It also validates the payload using a `Validator` if the argument is annotated with a Validation annotation.

  This `HandlerMethodArgumentResolver` should be ordered last as it supports all types and does not require the `Payload` annotation.

  Since:
    4.0
  Author:
    Rossen Stoyanchev, Brian Clozel, Stephane Nicoll

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `PayloadArgumentResolver(MessageConverter messageConverter, Validator validator)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected boolean` | `isEmptyPayload(Object payload)` Specify if the given `payload` is empty.
    `Object` | `resolveArgument(MethodParameter param, Message<?> message)` Resolves a method parameter into an argument value from a given message.
    `boolean` | `supportsParameter(MethodParameter parameter)` Whether the given method parameter is supported by this resolver.
    `protected void` | `validate(Message<?> message, MethodParameter parameter, Object target)`

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

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

- - ### Constructor Detail

    - #### PayloadArgumentResolver

          public PayloadArgumentResolver(MessageConverter messageConverter,
                                         Validator validator)

  - ### Method Detail

    - #### supportsParameter

          public boolean supportsParameter(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(MethodParameter param,
                                        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:
        `param` - the method parameter to resolve. This parameter must have previously been passed to `HandlerMethodArgumentResolver.supportsParameter(org.springframework.core.MethodParameter)` and it 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

    - #### isEmptyPayload

          protected boolean isEmptyPayload(Object payload)

      Specify if the given `payload` is empty.
      Parameters:
        `payload` - the payload to check (can be `null`)

    - #### validate

          protected void validate(Message<?> message,
                                  MethodParameter parameter,
                                  Object target)