Interface ParameterResolver<M>

Type Parameters:
M - the type of message object used by the handler invocation context, often DeserializingMessage
All Known Implementing Classes:
CurrentUserParameterResolver, DeserializingMessageParameterResolver, EntityParameterResolver, InputParameterResolver, MessageParameterResolver, MetadataParameterResolver, PayloadParameterResolver, SpringBeanParameterResolver, TriggerParameterResolver, TypedParameterResolver, UserParameterResolver, WebParamParameterResolver, WebPayloadParameterResolver, WebsocketHandlerDecorator
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface ParameterResolver<M>
Mechanism to resolve method parameters in message handler methods (e.g. those annotated with HandleEvent, HandleCommand, etc.).

A ParameterResolver determines how to inject values into the parameters of a handler method based on the message being handled, the parameter type, and other context. This allows custom logic to inject fields such as the payload, metadata, authenticated User, or other derived values.

Custom ParameterResolver ParameterResolvers can be registered with a FluxCapacitorBuilder to influence handler invocation logic across one or more message types.

  • Method Summary

    Modifier and Type
    Method
    Description
    default boolean
    Indicates whether this resolver contributes to determining handler method specificity when multiple handler candidates are available.
    default boolean
    filterMessage(M message, Parameter parameter)
    Determines whether a given message should be passed to a handler method based on this parameter's characteristics.
    default boolean
    matches(Parameter parameter, Annotation methodAnnotation, M value)
    Indicates whether the resolved value is compatible with the declared parameter type.
    resolve(Parameter parameter, Annotation methodAnnotation)
    Resolves a Parameter of a handler method into a value function based on the given message.
  • Method Details

    • resolve

      Function<M,Object> resolve(Parameter parameter, Annotation methodAnnotation)
      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 matches(java.lang.reflect.Parameter, java.lang.annotation.Annotation, M) is not implemented, this method must return null.

      Parameters:
      parameter - 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 matches(java.lang.reflect.Parameter, java.lang.annotation.Annotation, M) is not implemented.
    • matches

      default boolean matches(Parameter parameter, Annotation methodAnnotation, M value)
      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 resolve(java.lang.reflect.Parameter, java.lang.annotation.Annotation) and then verifies that the returned value (if any) is assignable to the parameter type.

      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
    • determinesSpecificity

      default boolean determinesSpecificity()
      Indicates whether this resolver contributes to determining handler method specificity when multiple handler candidates are available.

      If true, the resolver will participate in determining the most specific handler for a message. This is relevant when the system must choose between overlapping handler signatures, e.g. for a resolver of a message's payload.

      Returns:
      true if this resolver influences specificity decisions, false otherwise
    • filterMessage

      default boolean filterMessage(M message, Parameter parameter)
      Determines whether a given message should be passed to a handler method based on this parameter's characteristics.

      This hook is used after matches(java.lang.reflect.Parameter, java.lang.annotation.Annotation, M) is invoked but before resolve(java.lang.reflect.Parameter, java.lang.annotation.Annotation) and can thus be used to prevent other parameter resolvers from supplying a candidate for parameter injection.

      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