Class MessageParameterResolver

java.lang.Object
io.fluxzero.sdk.tracking.handling.MessageParameterResolver
All Implemented Interfaces:
ParameterResolver<Object>, PreparedParameterResolver<Object>

public class MessageParameterResolver extends Object implements PreparedParameterResolver<Object>
Resolves handler method parameters of type DeserializingMessage.

This allows handler methods to access the deserialization context, including message metadata, payload, and raw serialized content.

Useful when advanced information about the message is needed, such as the Fluxzero-assigned message index.

  • Constructor Details

    • MessageParameterResolver

      public MessageParameterResolver()
  • Method Details

    • resolve

      public Function<Object,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<Object>
      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.
    • prepare

      public Function<Object,Object> prepare(Parameter parameter, Annotation methodAnnotation)
      Description copied from interface: ParameterResolver
      Prepares a resolver function when this resolver can determine compatibility from the parameter and method annotation alone.

      The default returns null, which keeps resolution message-dependent. Implementations should override this only when ParameterResolver.matches(Parameter, Annotation, Object) would always be true for the supplied parameter, regardless of the message instance. Dynamic resolvers such as payload, trigger, or entity resolvers should keep the default behavior.

      Specified by:
      prepare in interface ParameterResolver<Object>
      Parameters:
      parameter - the parameter to resolve
      methodAnnotation - the annotation present on the handler method
      Returns:
      a prepared resolver, or null when resolution must remain message-dependent
    • resolveIfPossible

      public Function<Object,Object> resolveIfPossible(Parameter parameter, Annotation methodAnnotation, Object value)
      Description copied from interface: PreparedParameterResolver
      Returns a prepared resolver for the given message, or null when this resolver cannot handle the parameter.
      Specified by:
      resolveIfPossible in interface PreparedParameterResolver<Object>
    • matches

      public boolean matches(Parameter parameter, Annotation methodAnnotation, Object 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<Object>
      Parameters:
      parameter - 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
    • mayApply

      public boolean mayApply(Executable method, Class<?> targetClass)
      Description copied from interface: ParameterResolver
      Returns true if this resolver might apply to the given method. Implementations should perform only inexpensive checks and never throw.
      Specified by:
      mayApply in interface ParameterResolver<Object>
      Parameters:
      method - the handler method or constructor
      targetClass - the declaring or target class
      Returns:
      true if this resolver could apply, false otherwise