public final class CommandHandlerBuilder<Command,Event,State> extends java.lang.Object implements SignalHandlerBuilder<Command,Event,State>
CommandHandlers. Handling of commands are added with the match
methods and finally a CommandHandler is created with build().
Match statements are appended and evaluated in order, the first one to match is used. If no match is found when
evaluating the built CommandHandler for a given command a MatchError is thrown.
Instances should not be created by user code but instead accessed through ReplicatedEntity.commandHandlerBuilder(java.lang.Class<Command>).
| Constructor and Description |
|---|
CommandHandlerBuilder(java.lang.Class<Command> rootCommandClass) |
| Modifier and Type | Method and Description |
|---|---|
CommandHandler<Command,Event,State> |
build()
Build a command handler from the appended cases.
|
CommandHandler<Command,Event,State> |
matchAny(CommandToEffect<Command,Event,State> commandToEffect)
Match any command
|
<C extends Command> |
matchCommand(java.lang.Class<C> commandClass,
CommandToEffect<C,Event,State> commandToEffect)
Match any command which is an instance or a subtype of
commandClass |
<C extends Command> |
matchCommand(java.lang.Class<C> commandClass,
akka.japi.pf.FI.TypedPredicate<C> predicate,
CommandToEffect<C,Event,State> commandToEffect)
Match any command which is an instance or a subtype of
commandClass and which the given predicate returns true for. |
CommandHandlerBuilder<Command,Event,State> |
matchCommand(akka.japi.pf.FI.TypedPredicate<Command> predicate,
CommandToEffect<Command,Event,State> commandToEffect)
Match any command which the given
predicate returns true for |
<C extends Command> |
matchExactCommand(C exactly,
CommandToEffect<C,Event,State> commandToEffect)
Match any command which equals
exactly |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitbuildSignalHandlers, onReceiveTimeout, onTerminated, onTimer, signalHandlers_$eq, signalHandlerspublic CommandHandlerBuilder(java.lang.Class<Command> rootCommandClass)
public CommandHandler<Command,Event,State> build()
MatchError if applied to
a command that has no defined match.
The builder is reset to empty after build has been called.
build in interface SignalHandlerBuilder<Command,Event,State>public CommandHandler<Command,Event,State> matchAny(CommandToEffect<Command,Event,State> commandToEffect)
Builds and returns the handler since this will not let through any command to subsequent match statements
commandToEffect - (undocumented)public CommandHandlerBuilder<Command,Event,State> matchCommand(akka.japi.pf.FI.TypedPredicate<Command> predicate, CommandToEffect<Command,Event,State> commandToEffect)
predicate returns true forpredicate - (undocumented)commandToEffect - (undocumented)public <C extends Command> CommandHandlerBuilder<Command,Event,State> matchCommand(java.lang.Class<C> commandClass, CommandToEffect<C,Event,State> commandToEffect)
commandClass
Throws java.lang.IllegalArgumentException if commandClass is not a subtype of the root Command this builder was created with
commandClass - (undocumented)commandToEffect - (undocumented)public <C extends Command> CommandHandlerBuilder<Command,Event,State> matchCommand(java.lang.Class<C> commandClass, akka.japi.pf.FI.TypedPredicate<C> predicate, CommandToEffect<C,Event,State> commandToEffect)
commandClass and which the given predicate returns true for.
Throws java.lang.IllegalArgumentException if commandClass is not a subtype of the root Command this builder was created with
commandClass - (undocumented)predicate - (undocumented)commandToEffect - (undocumented)public <C extends Command> CommandHandlerBuilder<Command,Event,State> matchExactCommand(C exactly, CommandToEffect<C,Event,State> commandToEffect)
exactly
Throws java.lang.IllegalArgumentException if exactly is not a subtype of the root Command this builder was created with
exactly - (undocumented)commandToEffect - (undocumented)