Interface MessageFilter<M>
- Type Parameters:
M- the message type to evaluate
- All Known Implementing Classes:
HandleCustomFilter, HandleDocumentFilter, PayloadFilter, SegmentFilter, TriggerParameterResolver
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Defines a predicate that determines whether a given message is applicable to a handler method.
This interface enables conditional dispatching of messages to handler methods based on runtime message properties, handler annotations, and method metadata.
MessageFilters can be composed using and(), making them useful for defining cross-cutting message
acceptance rules (e.g. for authentication, message type filtering, etc.).
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiondefault MessageFilter<M> and(@NonNull MessageFilter<? super M> second) Combines this filter with another using logical AND.getLeastSpecificAllowedClass(Executable executable, Class<? extends Annotation> handlerAnnotation) Provides the least specific class type that is allowed to match this filter for a given method and annotation.booleantest(M message, Executable executable, Class<? extends Annotation> handlerAnnotation) Evaluates whether a message should be handled by a given method annotated with a specific handler annotation.
-
Method Details
-
test
Evaluates whether a message should be handled by a given method annotated with a specific handler annotation.- Parameters:
message- the message instance to evaluateexecutable- the candidate handler methodhandlerAnnotation- the annotation that marks the method as a handler (e.g.@HandleCommand)- Returns:
trueif the message is accepted by this filter for the given handler method
-
getLeastSpecificAllowedClass
default Optional<Class<?>> getLeastSpecificAllowedClass(Executable executable, Class<? extends Annotation> handlerAnnotation) Provides the least specific class type that is allowed to match this filter for a given method and annotation.This can be used to restrict or optimize handler matching, especially when working with inheritance or interface hierarchies.
- Parameters:
executable- the candidate handler methodhandlerAnnotation- the annotation present on the handler method- Returns:
- an optional type indicating the base class that messages must extend or implement
-
and
Combines this filter with another using logical AND. The resulting filter passes only if both filters pass.- Parameters:
second- anotherMessageFilterto combine with- Returns:
- a new
MessageFilterthat passes only if both this and the second filter pass
-