java.lang.Object
io.fluxzero.sdk.web.WebPayloadParameterResolver
- All Implemented Interfaces:
io.fluxzero.common.handling.ParameterResolver<HasMessage>
public class WebPayloadParameterResolver
extends Object
implements io.fluxzero.common.handling.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
validatePayloadistrue, the resolved payload is validated usingassertValid(). - If
authoriseUseristrue, the currentUsermust be authorized to execute the payload’s type viaassertAuthorized().
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanmatches(Parameter parameter, Annotation methodAnnotation, HasMessage value) Determines whether this resolver should be used for the given method parameter.booleanmayApply(Executable method, Class<?> targetClass) resolve(Parameter p, Annotation methodAnnotation) Resolves the value for the given method parameter by converting the message payload to the expected parameter type.booleantest(HasMessage m, Parameter p) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.fluxzero.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:
resolvein interfaceio.fluxzero.common.handling.ParameterResolver<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
HasMessageinstance
-
test
- Specified by:
testin interfaceio.fluxzero.common.handling.ParameterResolver<HasMessage>
-
matches
Determines whether this resolver should be used for the given method parameter. This resolver is active for any method annotated withHandleWebor any annotation that is meta-annotated with it.- Specified by:
matchesin interfaceio.fluxzero.common.handling.ParameterResolver<HasMessage>- Parameters:
parameter- the method parametermethodAnnotation- the annotation on the methodvalue- the incoming message- Returns:
trueif the resolver is applicable to this parameter
-
mayApply
- Specified by:
mayApplyin interfaceio.fluxzero.common.handling.ParameterResolver<HasMessage>
-