Class PayloadParameterResolver

java.lang.Object
io.fluxzero.sdk.tracking.handling.PayloadParameterResolver
All Implemented Interfaces:
ParameterResolver<HasMessage>

public class PayloadParameterResolver extends Object implements ParameterResolver<HasMessage>
Resolves handler method parameters by injecting the message payload.

This resolver matches a parameter when its declared type is assignable from the actual payload class of the incoming message.

This resolver is typically used in conjunction with filters such as PayloadFilter to determine handler compatibility based on payload types.

Special care is taken to allow null payloads for parameters that are declared nullable, which can occur during upcasting or transformation pipelines.

See Also:
  • Constructor Details

    • PayloadParameterResolver

      public PayloadParameterResolver()
  • Method Details

    • matches

      public boolean matches(Parameter p, Annotation methodAnnotation, HasMessage value)
      Description copied from interface: ParameterResolver
      Indicates whether the resolved value is compatible with the declared parameter type.

      This method helps determine whether the parameter can be injected for a given message. It first invokes ParameterResolver.resolve(Parameter, Annotation) and then verifies that the returned value (if any) is assignable to the parameter type.

      Specified by:
      matches in interface ParameterResolver<HasMessage>
      Parameters:
      p - the parameter being checked
      methodAnnotation - the annotation on the handler method
      value - the message instance to use for resolution
      Returns:
      true if the parameter can be resolved and assigned to, false otherwise
    • resolve

      public Function<HasMessage, Object> resolve(Parameter p, Annotation methodAnnotation)
      Description copied from interface: ParameterResolver
      Resolves a Parameter of a handler method into a value function based on the given message.

      If the parameter cannot be resolved by this resolver and ParameterResolver.matches(Parameter, Annotation, M) is not implemented, this method must return null.

      Specified by:
      resolve in interface ParameterResolver<HasMessage>
      Parameters:
      p - the parameter to resolve
      methodAnnotation - the annotation present on the handler method (e.g., @HandleEvent)
      Returns:
      a function that takes a message and returns a value to be injected into the method parameter, or null if the parameter cannot be resolved and ParameterResolver.matches(Parameter, Annotation, M) is not implemented.
    • test

      public boolean test(HasMessage message, Parameter parameter)
      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(Parameter, Annotation, M) is invoked but before ParameterResolver.resolve(Parameter, Annotation) and can thus be used to prevent other parameter resolvers from supplying a candidate for parameter injection.

      Specified by:
      test in interface ParameterResolver<HasMessage>
      Parameters:
      message - the message being evaluated
      parameter - the method parameter to test
      Returns:
      true if the message should be processed, false if it should be filtered out
    • determinesSpecificity

      public boolean determinesSpecificity()
      Indicates that this resolver contributes to disambiguating handler methods when multiple handlers are present in the same target class.

      This is useful when more than one method matches a message, and the framework must decide which method is more specific. If this returns true, the resolver's presence and compatibility with the parameter may influence which handler is selected.

      Specified by:
      determinesSpecificity in interface ParameterResolver<HasMessage>
      Returns:
      true, signaling that this resolver helps determine method specificity