Interface HandlerFilter

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 HandlerFilter
Represents a predicate used to determine whether a given method should be considered a valid message handler.

A HandlerFilter operates on the class (typically an application component) and a method, and can be used to include or exclude handler methods during the handler discovery process.

It supports composition via and, or, and negate, allowing developers to build complex filtering logic declaratively.

Usage Example

HandlerFilter publicMethodsOnly = (type, method) -> Modifier.isPublic(method.getModifiers());
HandlerFilter annotatedOnly = (type, method) -> method.isAnnotationPresent(HandleCommand.class);
HandlerFilter combined = publicMethodsOnly.and(annotatedOnly);
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final HandlerFilter
     
  • Method Summary

    Modifier and Type
    Method
    Description
    and(@NonNull HandlerFilter other)
    Combines this filter with another using logical AND.
    Inverts the current filter.
    or(@NonNull HandlerFilter other)
    Combines this filter with another using logical OR.
    boolean
    test(Class<?> ownerType, Executable executable)
    Evaluates whether the specified method on the given class should be considered a valid handler.
  • Field Details

  • Method Details

    • test

      boolean test(Class<?> ownerType, Executable executable)
      Evaluates whether the specified method on the given class should be considered a valid handler.
      Parameters:
      ownerType - the class that declares the handler method
      executable - the candidate method to evaluate
      Returns:
      true if the method should be included as a handler, false otherwise
    • and

      default HandlerFilter and(@NonNull @NonNull HandlerFilter other)
      Combines this filter with another using logical AND. The resulting filter passes only if both filters pass.
      Parameters:
      other - another HandlerFilter to combine with
      Returns:
      a new HandlerFilter representing the conjunction of both filters
    • negate

      default HandlerFilter negate()
      Inverts the current filter. The resulting filter passes only if the original filter does not.
      Returns:
      a new HandlerFilter representing the logical negation of this filter
    • or

      default HandlerFilter or(@NonNull @NonNull HandlerFilter other)
      Combines this filter with another using logical OR. The resulting filter passes if either of the filters passes.
      Parameters:
      other - another HandlerFilter to combine with
      Returns:
      a new HandlerFilter representing the disjunction of both filters