Class PayloadFilter
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 TypeMethodDescriptiondefault io.fluxzero.common.handling.MessageFilter<HasMessage> and(@NonNull io.fluxzero.common.handling.MessageFilter<? super HasMessage> arg0) getLeastSpecificAllowedClass(Executable executable, Class<? extends Annotation> handlerAnnotation) booleantest(HasMessage message, Executable executable, Class<? extends Annotation> handlerAnnotation)
-
Constructor Details
-
PayloadFilter
public PayloadFilter()
-
-
Method Details
-
test
public boolean test(HasMessage message, Executable executable, Class<? extends Annotation> handlerAnnotation) -
getLeastSpecificAllowedClass
public Optional<Class<?>> getLeastSpecificAllowedClass(Executable executable, Class<? extends Annotation> handlerAnnotation) -
and
default io.fluxzero.common.handling.MessageFilter<HasMessage> and(@NonNull @NonNull io.fluxzero.common.handling.MessageFilter<? super HasMessage> arg0)
-