Class JsonPayloadParameterResolver

java.lang.Object
io.fluxzero.sdk.tracking.handling.JsonPayloadParameterResolver

public class JsonPayloadParameterResolver extends Object
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 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 using HasMessage.getPayloadAs(java.lang.reflect.Type).
      Parameters:
      parameter - the handler method parameter to resolve
      methodAnnotation - 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 JsonNode and the payload format of the message equals Data.JSON_FORMAT.

    • mayApply

      public boolean mayApply(Executable method, Class<?> targetClass)
      Indicates whether this resolver may apply to the given method.

      This implementation returns true if any of the method's parameters are assignable to JsonNode.

    • determinesSpecificity

      default boolean determinesSpecificity()
    • test

      default boolean test(DeserializingMessage arg0, Parameter arg1)