Class JsonPayloadParameterResolver
java.lang.Object
io.fluxzero.sdk.tracking.handling.JsonPayloadParameterResolver
A
ParameterResolver that converts the message payload to the parameter's declared type
if that type is assignable to JsonNode.
This resolver supports handler parameters that accept JSON payloads directly as JsonNode
instances. When matched, it uses HasMessage.getPayloadAs(java.lang.reflect.Type) to
deserialize the message payload into the declared parameter type.
Example usage:
@HandleCommand(allowedClasses = CreateProject.class)
void handle(JsonNode command) {
// The message payload is automatically converted to a JsonNode instance
}
This resolver only applies to handler methods or constructors that declare at least one parameter
of a type assignable to JsonNode. Additionally, the format of the message payload must be
JSON, as indicated by Data.JSON_FORMAT.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondefault booleanbooleanmatches(Parameter parameter, Annotation methodAnnotation, DeserializingMessage value) Determines whether this resolver matches the given parameter.booleanmayApply(Executable method, Class<?> targetClass) Indicates whether this resolver may apply to the given method.resolve(Parameter parameter, Annotation methodAnnotation) Returns a function that converts the message payload to the expected parameter type usingHasMessage.getPayloadAs(java.lang.reflect.Type).default booleantest(DeserializingMessage arg0, Parameter arg1)
-
Constructor Details
-
JsonPayloadParameterResolver
public JsonPayloadParameterResolver()
-
-
Method Details
-
resolve
public Function<DeserializingMessage, Object> resolve(Parameter parameter, Annotation methodAnnotation) Returns a function that converts the message payload to the expected parameter type usingHasMessage.getPayloadAs(java.lang.reflect.Type).- Parameters:
parameter- the handler method parameter to resolvemethodAnnotation- the handler method annotation, if present- Returns:
- a function that produces the converted JSON payload value
-
matches
public boolean matches(Parameter parameter, Annotation methodAnnotation, DeserializingMessage value) Determines whether this resolver matches the given parameter.A parameter is considered a match if it is assignable to
JsonNodeand the payload format of the message equalsData.JSON_FORMAT. -
mayApply
Indicates whether this resolver may apply to the given method.This implementation returns
trueif any of the method's parameters are assignable toJsonNode. -
determinesSpecificity
default boolean determinesSpecificity() -
test
-