Interface HandlerMethod<M>

Type Parameters:
M - the message type
All Superinterfaces:
HandlerDescriptor
All Known Implementing Classes:
HandlerMethod.DelegatingHandlerMethod

public interface HandlerMethod<M> extends HandlerDescriptor
A reusable, target-bound handler method.

Unlike a HandlerInvoker, a HandlerMethod is not resolved for one specific message. It can be checked and invoked repeatedly for messages that match the same method and target.

  • Method Details

    • canHandle

      boolean canHandle(M message)
      Returns whether this method can handle the supplied message.
      Parameters:
      message - the message to check
      Returns:
      true if this handler method can handle the message
    • invoke

      default Object invoke(M message)
      Invokes this handler method for the supplied message using the default result-combining strategy.
      Parameters:
      message - the message to handle
      Returns:
      the handler result
    • invoke

      Object invoke(M message, BiFunction<Object,Object,Object> resultCombiner)
      Invokes this handler method for the supplied message and combines multiple results using the given combiner.
      Parameters:
      message - the message to handle
      resultCombiner - function to combine multiple results
      Returns:
      the handler result