Class AnnotatedCommandHandler
- java.lang.Object
-
- dk.cloudcreate.essentials.reactive.command.AnnotatedCommandHandler
-
- All Implemented Interfaces:
CommandHandler
public abstract class AnnotatedCommandHandler extends Object implements CommandHandler
Extending this class will allow you to colocate multiple related Command handling methods inside the same class and use it together with theLocalCommandBus
Each method must accept a single Command argument, may return a value or return void and be annotated with theEventHandlerannotation.
The method argument type is matched against the concrete command type usingClass.isAssignableFrom(Class).
The method accessibility can be any combination of private, protected, public, etc.
Example:{@code public class OrdersCommandHandler extends AnnotatedCommandHandler {
-
-
Constructor Summary
Constructors Constructor Description AnnotatedCommandHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancanHandle(Class<?> commandType)This method is called by theLocalCommandBusto check if this concreteCommandHandlersupports a given command typeObjecthandle(Object command)This method is called by theLocalCommandBusafter it has determined that only thisCommandHandlerinstance is capable of handling the command (based on the commands type)
-
-
-
Method Detail
-
canHandle
public boolean canHandle(Class<?> commandType)
Description copied from interface:CommandHandlerThis method is called by theLocalCommandBusto check if this concreteCommandHandlersupports a given command type- Specified by:
canHandlein interfaceCommandHandler- Parameters:
commandType- the type of command being processed by theLocalCommandBus- Returns:
- true if this command handler can handle a command of the given type - otherwise it must return false
-
handle
public final Object handle(Object command)
Description copied from interface:CommandHandlerThis method is called by theLocalCommandBusafter it has determined that only thisCommandHandlerinstance is capable of handling the command (based on the commands type)- Specified by:
handlein interfaceCommandHandler- Parameters:
command- the command- Returns:
- the result of handling the command (if any)
-
-