Class HandlerInspector.ObjectHandlerMatcher<M>
java.lang.Object
io.fluxzero.common.handling.HandlerInspector.ObjectHandlerMatcher<M>
- All Implemented Interfaces:
HandlerMatcher<Object,M>
- Enclosing class:
HandlerInspector
public static class HandlerInspector.ObjectHandlerMatcher<M>
extends Object
implements HandlerMatcher<Object,M>
A composite
HandlerMatcher that delegates to a list of individual matchers.
Supports invoking one or multiple methods depending on configuration.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbindHandlerMethod(Object target) Binds this matcher to a stable target instance, if it can expose a reusable method plan.booleanReturns whether the given message can be handled by a handler instance of typeT.getInvoker(Object target, M message) Attempts to resolve aHandlerInvokerfor the given target instance and message.getInvokerOrNull(Object target, M message) Attempts to resolve aHandlerInvokerfor the given target instance and message.matchingMethods(M message) Returns a stream of methods from the target class that match the given message.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface HandlerMatcher
or
-
Constructor Details
-
ObjectHandlerMatcher
public ObjectHandlerMatcher()
-
-
Method Details
-
canHandle
Description copied from interface:HandlerMatcherReturns whether the given message can be handled by a handler instance of typeT. This is a lightweight check and may be used for fast filtering or diagnostics.- Specified by:
canHandlein interfaceHandlerMatcher<Object,M> - Parameters:
message- the message to check- Returns:
trueif the matcher may be able to produce an invoker for the given message
-
matchingMethods
Description copied from interface:HandlerMatcherReturns a stream of methods from the target class that match the given message. Typically used for diagnostics or documentation tools.- Specified by:
matchingMethodsin interfaceHandlerMatcher<Object,M> - Parameters:
message- the message to match against- Returns:
- a stream of matching
Executablehandler methods
-
getInvoker
Description copied from interface:HandlerMatcherAttempts to resolve aHandlerInvokerfor the given target instance and message.- Specified by:
getInvokerin interfaceHandlerMatcher<Object,M> - Parameters:
target- the handler objectmessage- the message to be handled- Returns:
- an optional invoker if the message is supported by the target; empty otherwise
-
getInvokerOrNull
Description copied from interface:HandlerMatcherAttempts to resolve aHandlerInvokerfor the given target instance and message.This is a lower-allocation counterpart to
HandlerMatcher.getInvoker(Object, Object)for internal hot paths.- Specified by:
getInvokerOrNullin interfaceHandlerMatcher<Object,M> - Parameters:
target- the handler objectmessage- the message to be handled- Returns:
- an invoker if the message is supported by the target;
nullotherwise
-
bindHandlerMethod
Description copied from interface:HandlerMatcherBinds this matcher to a stable target instance, if it can expose a reusable method plan.Most matcher implementations may return
null. Returning a method is only appropriate when the method metadata and target are stable for all matching messages.- Specified by:
bindHandlerMethodin interfaceHandlerMatcher<Object,M> - Parameters:
target- the handler object- Returns:
- a reusable handler method, or
nullwhen the matcher requires per-message invokers
-