public class PayloadArgumentResolver extends java.lang.Object implements HandlerMethodArgumentResolver
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.
Modifier and Type | Field and Description |
---|---|
private MessageConverter |
converter |
private Validator |
validator |
Constructor and Description |
---|
PayloadArgumentResolver(MessageConverter messageConverter,
Validator validator) |
Modifier and Type | Method and Description |
---|---|
private java.lang.String |
getParameterName(MethodParameter param) |
protected boolean |
isEmptyPayload(java.lang.Object payload)
Specify if the given
payload is empty. |
java.lang.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,
java.lang.Object target) |
private final MessageConverter converter
private final Validator validator
public PayloadArgumentResolver(MessageConverter messageConverter, Validator validator)
public boolean supportsParameter(MethodParameter parameter)
HandlerMethodArgumentResolver
supportsParameter
in interface HandlerMethodArgumentResolver
parameter
- the method parameter to checktrue
if this resolver supports the supplied parameter;
false
otherwisepublic java.lang.Object resolveArgument(MethodParameter param, Message<?> message) throws java.lang.Exception
HandlerMethodArgumentResolver
resolveArgument
in interface HandlerMethodArgumentResolver
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 messagenull
.java.lang.Exception
- in case of errors with the preparation of argument valuesprivate java.lang.String getParameterName(MethodParameter param)
protected boolean isEmptyPayload(java.lang.Object payload)
payload
is empty.payload
- the payload to check (can be null
)protected void validate(Message<?> message, MethodParameter parameter, java.lang.Object target)