- All Implemented Interfaces:
io.fluxzero.common.handling.MessageFilter<HasMessage>
MessageFilter used to restrict message handling based on the payload type.
This filter determines whether a handler method should be invoked based on whether the incoming message's payload
class is compatible with the types explicitly allowed in the method's handler annotation (e.g.,
@HandleCommand, @HandleQuery, etc.) via the allowedClasses method.
The filtering logic checks if the method has a supported handler annotation and whether the annotation defines a non-empty set of allowed payload types. If so, the message's payload class must be assignable to at least one of those allowed classes for the handler to be eligible.
If no types are specified in the annotation, the handler is assumed to be permissive and accepts all types. In
those cases a method is typically filtered by the PayloadParameterResolver instead.
Example Usage
Given a handler:
@HandleCommand(allowedClasses = {CommandA.class, CommandB.class})
public void handle(DeserializingMessage message) { ... }
This filter ensures that only messages with a `CommandA` or `CommandB` payload (or their subtypes) are dispatched to
the method.- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetLeastSpecificAllowedClass(Executable executable, Class<? extends Annotation> handlerAnnotation) booleantest(HasMessage message, Executable executable, Class<? extends Annotation> handlerAnnotation) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.fluxzero.common.handling.MessageFilter
and
-
Constructor Details
-
PayloadFilter
public PayloadFilter()
-
-
Method Details
-
test
public boolean test(HasMessage message, Executable executable, Class<? extends Annotation> handlerAnnotation) - Specified by:
testin interfaceio.fluxzero.common.handling.MessageFilter<HasMessage>
-
getLeastSpecificAllowedClass
public Optional<Class<?>> getLeastSpecificAllowedClass(Executable executable, Class<? extends Annotation> handlerAnnotation) - Specified by:
getLeastSpecificAllowedClassin interfaceio.fluxzero.common.handling.MessageFilter<HasMessage>
-