Package io.fluxcapacitor.javaclient.web
Class WebPayloadParameterResolver
java.lang.Object
io.fluxcapacitor.javaclient.web.WebPayloadParameterResolver
- All Implemented Interfaces:
ParameterResolver<HasMessage>
Resolves a method parameter from the payload of a
WebRequest
.
This resolver is only applied to methods annotated with HandleWeb
or any of its meta-annotations (e.g.
HandlePost
). It converts the deserialized payload to the method parameter's declared type.
Optionally, the resolver can enforce validation and authorization:
- If
validatePayload
istrue
, the resolved payload is validated usingassertValid()
. - If
authoriseUser
istrue
, the currentUser
must be authorized to execute the payload’s type viaassertAuthorized()
.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
filterMessage
(HasMessage m, Parameter p) Determines whether a given message should be passed to a handler method based on this parameter's characteristics.boolean
matches
(Parameter parameter, Annotation methodAnnotation, HasMessage value) Determines whether this resolver should be used for the given method parameter.resolve
(Parameter p, Annotation methodAnnotation) Resolves the value for the given method parameter by converting the message payload to the expected parameter type.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.fluxcapacitor.common.handling.ParameterResolver
determinesSpecificity
-
Constructor Details
-
WebPayloadParameterResolver
public WebPayloadParameterResolver()
-
-
Method Details
-
resolve
Resolves the value for the given method parameter by converting the message payload to the expected parameter type. If configured, it also validates and authorizes the payload.- Specified by:
resolve
in interfaceParameterResolver<HasMessage>
- Parameters:
p
- the method parameter to resolvemethodAnnotation
- the annotation on the handler method (typically@HandleWeb
)- Returns:
- a function that resolves the parameter from a
HasMessage
instance
-
filterMessage
Description copied from interface:ParameterResolver
Determines whether a given message should be passed to a handler method based on this parameter's characteristics.This hook is used after
ParameterResolver.matches(java.lang.reflect.Parameter, java.lang.annotation.Annotation, M)
is invoked but beforeParameterResolver.resolve(java.lang.reflect.Parameter, java.lang.annotation.Annotation)
and can thus be used to prevent other parameter resolvers from supplying a candidate for parameter injection.- Specified by:
filterMessage
in interfaceParameterResolver<HasMessage>
- Parameters:
m
- the message being evaluatedp
- the method parameter to test- Returns:
true
if the message should be processed,false
if it should be filtered out
-
matches
Determines whether this resolver should be used for the given method parameter. This resolver is active for any method annotated withHandleWeb
or any annotation that is meta-annotated with it.- Specified by:
matches
in interfaceParameterResolver<HasMessage>
- Parameters:
parameter
- the method parametermethodAnnotation
- the annotation on the methodvalue
- the incoming message- Returns:
true
if the resolver is applicable to this parameter
-