Class DefaultHandler<M>
java.lang.Object
io.fluxzero.common.handling.DefaultHandler<M>
- All Implemented Interfaces:
Handler<M>
-
Nested Class Summary
Nested classes/interfaces inherited from interface Handler
Handler.DelegatingHandler<M> -
Constructor Summary
ConstructorsConstructorDescriptionDefaultHandler(Class<?> targetClass, Function<M, ?> targetSupplier, HandlerMatcher<Object, M> handlerMatcher) -
Method Summary
Modifier and TypeMethodDescriptionstatic <M> DefaultHandler<M> forTarget(Class<?> targetClass, Object target, HandlerMatcher<Object, M> handlerMatcher) getHandlerMethodOrNull(M message) Returns a reusableHandlerMethodcapable of processing the given message, ornullwhen unavailable.getInvoker(M message) Returns aHandlerInvokercapable of processing the given message, if available.getInvokerOrNull(M message) Returns aHandlerInvokercapable of processing the given message, ornullwhen unavailable.Class<?> Returns the class of the handler's target object.toString()
-
Constructor Details
-
DefaultHandler
-
-
Method Details
-
forTarget
public static <M> DefaultHandler<M> forTarget(Class<?> targetClass, Object target, HandlerMatcher<Object, M> handlerMatcher) -
getTargetClass
Description copied from interface:HandlerReturns the class of the handler's target object. This may be used for reflective operations, logging, or framework-level behavior.- Specified by:
getTargetClassin interfaceHandler<M>- Returns:
- the class of the handler's target
-
getInvoker
Description copied from interface:HandlerReturns aHandlerInvokercapable of processing the given message, if available.- Specified by:
getInvokerin interfaceHandler<M>- Parameters:
message- the message to be handled- Returns:
- an optional
HandlerInvokerif this handler can handle the message; otherwiseOptional.empty()
-
getInvokerOrNull
Description copied from interface:HandlerReturns aHandlerInvokercapable of processing the given message, ornullwhen unavailable.This is a lower-allocation counterpart to
Handler.getInvoker(Object)for internal hot paths. Implementations that can resolve an invoker without creating anOptionalshould override this method.- Specified by:
getInvokerOrNullin interfaceHandler<M>- Parameters:
message- the message to be handled- Returns:
- an invoker if this handler can handle the message;
nullotherwise
-
getHandlerMethodOrNull
Description copied from interface:HandlerReturns a reusableHandlerMethodcapable of processing the given message, ornullwhen unavailable.This is an optional lower-allocation path for handlers whose target and method plan can be reused across messages. Implementations that cannot expose a stable method should return
nulland rely onHandler.getInvokerOrNull(Object).- Specified by:
getHandlerMethodOrNullin interfaceHandler<M>- Parameters:
message- the message to be handled- Returns:
- a handler method if this handler can handle the message through a reusable method;
nullotherwise
-
toString
-