Class CommandHandlerWithReplyBuilder<Command,Event,State>
- java.lang.Object
-
- akka.persistence.typed.javadsl.CommandHandlerWithReplyBuilder<Command,Event,State>
-
public final class CommandHandlerWithReplyBuilder<Command,Event,State> extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description CommandHandlerWithReplyBuilder()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description CommandHandlerWithReply<Command,Event,State>build()static <Command,Event,State>
CommandHandlerWithReplyBuilder<Command,Event,State>builder()CommandHandlerWithReplyBuilderByState<Command,Event,State,State>forAnyState()The handlers defined by this builder are used for any state.CommandHandlerWithReplyBuilderByState<Command,Event,State,State>forNonNullState()The handlers defined by this builder are used for any notnullstate.CommandHandlerWithReplyBuilderByState<Command,Event,State,State>forNullState()The handlers defined by this builder are used when the state isnull.<S extends State>
CommandHandlerWithReplyBuilderByState<Command,Event,S,State>forState(java.lang.Class<S> stateClass, java.util.function.Predicate<S> statePredicate)Use this method to define command handlers that are selected when the passed predicate holds true for a given subtype of your model.CommandHandlerWithReplyBuilderByState<Command,Event,State,State>forState(java.util.function.Predicate<State> statePredicate)Use this method to define command handlers that are selected when the passed predicate holds true.<S extends State>
CommandHandlerWithReplyBuilderByState<Command,Event,S,State>forStateType(java.lang.Class<S> stateClass)Use this method to define command handlers for a given subtype of your model.
-
-
-
Method Detail
-
builder
public static <Command,Event,State> CommandHandlerWithReplyBuilder<Command,Event,State> builder()
-
forState
public CommandHandlerWithReplyBuilderByState<Command,Event,State,State> forState(java.util.function.Predicate<State> statePredicate)
Use this method to define command handlers that are selected when the passed predicate holds true.Note: command handlers are matched in the order they are added. Once a matching is found, it's selected for handling the command and no further lookup is done. Therefore you must make sure that their matching conditions don't overlap, otherwise you risk to 'shadow' part of your command handlers.
- Parameters:
statePredicate- The handlers defined by this builder are used when thestatePredicateistrue- Returns:
- A new, mutable, CommandHandlerWithReplyBuilderByState
-
forState
public <S extends State> CommandHandlerWithReplyBuilderByState<Command,Event,S,State> forState(java.lang.Class<S> stateClass, java.util.function.Predicate<S> statePredicate)
Use this method to define command handlers that are selected when the passed predicate holds true for a given subtype of your model. Useful when the model is defined as class hierarchy.Note: command handlers are matched in the order they are added. Once a matching is found, it's selected for handling the command and no further lookup is done. Therefore you must make sure that their matching conditions don't overlap, otherwise you risk to 'shadow' part of your command handlers.
- Parameters:
stateClass- The handlers defined by this builder are used when the state is an instance of thestateClassstatePredicate- The handlers defined by this builder are used when thestatePredicateistrue- Returns:
- A new, mutable, CommandHandlerWithReplyBuilderByState
-
forStateType
public <S extends State> CommandHandlerWithReplyBuilderByState<Command,Event,S,State> forStateType(java.lang.Class<S> stateClass)
Use this method to define command handlers for a given subtype of your model. Useful when the model is defined as class hierarchy.Note: command handlers are matched in the order they are added. Once a matching is found, it's selected for handling the command and no further lookup is done. Therefore you must make sure that their matching conditions don't overlap, otherwise you risk to 'shadow' part of your command handlers.
- Parameters:
stateClass- The handlers defined by this builder are used when the state is an instance of thestateClass.- Returns:
- A new, mutable, CommandHandlerWithReplyBuilderByState
-
forNullState
public CommandHandlerWithReplyBuilderByState<Command,Event,State,State> forNullState()
The handlers defined by this builder are used when the state isnull. This variant is particular useful when the empty state of your model is defined asnull.Note: command handlers are matched in the order they are added. Once a matching is found, it's selected for handling the command and no further lookup is done. Therefore you must make sure that their matching conditions don't overlap, otherwise you risk to 'shadow' part of your command handlers.
- Returns:
- A new, mutable, CommandHandlerWithReplyBuilderByState
-
forNonNullState
public CommandHandlerWithReplyBuilderByState<Command,Event,State,State> forNonNullState()
The handlers defined by this builder are used for any notnullstate.Note: command handlers are matched in the order they are added. Once a matching is found, it's selected for handling the command and no further lookup is done. Therefore you must make sure that their matching conditions don't overlap, otherwise you risk to 'shadow' part of your command handlers.
- Returns:
- A new, mutable, CommandHandlerWithReplyBuilderByState
-
forAnyState
public CommandHandlerWithReplyBuilderByState<Command,Event,State,State> forAnyState()
The handlers defined by this builder are used for any state. This variant is particular useful for models that have a single type (ie: no class hierarchy).Note: command handlers are matched in the order they are added. Once a matching is found, it's selected for handling the command and no further lookup is done. Therefore you must make sure that their matching conditions don't overlap, otherwise you risk to 'shadow' part of your command handlers. Extra care should be taken when using
forAnyState()as it will match any state. Any command handler define after it will never be reached.- Returns:
- A new, mutable, CommandHandlerWithReplyBuilderByState
-
build
public CommandHandlerWithReply<Command,Event,State> build()
-
-