Class HandlerInspector.ObjectHandlerMatcher<M>
- All Implemented Interfaces:
HandlerMatcher<Object,M>
- Enclosing class:
HandlerInspector
HandlerMatcher that delegates to a list of individual matchers.
Supports invoking one or multiple methods depending on configuration.
-
Constructor Summary
ConstructorsConstructorDescriptionObjectHandlerMatcher(List<HandlerMatcher<Object, M>> methodHandlers, boolean invokeMultipleMethods) -
Method Summary
Modifier and TypeMethodDescriptionbindHandlerMethod(Object target) Binds this matcher to a stable target instance, if it can expose a reusable method plan.bindHandlerMethodPlanner(Object target) Creates a planner whose invocation plans call handler methods on the supplied target instance.Creates a planner for handler methods declared on the payload itself.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.prepareHandlerMethod(Object target, M message) Selects and prepares a handler method on the supplied target for 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(List<HandlerMatcher<Object, M>> methodHandlers, boolean invokeMultipleMethods)
-
-
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
-
prepareHandlerMethod
Description copied from interface:HandlerMatcherSelects and prepares a handler method on the supplied target for the given message.The default uses
HandlerMatcher.bindHandlerMethodPlanner(Object)when available. Returningnulldoes not reject the message; it tells the caller to use regular per-message matching instead.- Specified by:
prepareHandlerMethodin interfaceHandlerMatcher<Object,M> - Parameters:
target- the object that contains the handler methodmessage- the representative message- Returns:
- the reusable invocation plan, or
nullwhen no method matches or safe preparation is unsupported
-
bindHandlerMethodPlanner
Description copied from interface:HandlerMatcherCreates a planner whose invocation plans call handler methods on the supplied target instance.The planner may be cached and used concurrently. The default returns
null, so matchers are not required to support prepared invocation.- Specified by:
bindHandlerMethodPlannerin interfaceHandlerMatcher<Object,M> - Parameters:
target- the object that contains the handler methods- Returns:
- a thread-safe planner bound to the target, or
nullwhen preparation is unsupported
-
bindPayloadHandlerMethodPlanner
Description copied from interface:HandlerMatcherCreates a planner for handler methods declared on the payload itself.The returned planner may be reused for many payload objects. Its plans must therefore obtain the target from
HandlerInput.getPayload()for every invocation and must never retain the representative payload used to select the method.- Specified by:
bindPayloadHandlerMethodPlannerin interfaceHandlerMatcher<Object,M> - Returns:
- a thread-safe payload-target planner, or
nullwhen this matcher cannot safely prepare one
-