@Retention(value=RUNTIME) @Target(value=METHOD) public @interface Command
A commanding method must:
CommandMessage, if there is only one command to be generated; or an
Iterableof command messages for two or more commands;
A commanding method may accept a context of the incoming message
EventContext correspondingly) as the second parameter, if
handling of the command requires its context.
If the annotation is applied to a method which doesn't satisfy any of these requirements, this method is not considered a command handler and is not registered for command generation.
A commanding method may throw a
if, and only if it accepts a command message. This means that the incoming command
may be either rejected, or substituting command(s) must be generated.
Throwing other types in command transforming methods in not allowed.
Commanding methods accepting events or rejections may not throw.
A commanding method should have package-private access. It will allow
calling this method from tests. The method should not be
public because it is not
supposed to be called directly.
An application can either handle an incoming command or transform it into one or more commands that will be handled instead. Because of this, a commanding method cannot accept a command message, if there is already a command handling method which accepts the command message type.
If a commanding method accepts a command type which is also handled by the application by another method, a run-time error will occur. This also means that an application cannot have two commanding methods that accept the same command type.