akka.persistence.typed.javadsl
EventHandlerBuilderByState
Companion object EventHandlerBuilderByState
final class EventHandlerBuilderByState[S <: State, State >: Null, Event] extends AnyRef
- Alphabetic
- By Inheritance
- EventHandlerBuilderByState
- AnyRef
- Any
- by any2stringadd
- by StringFormat
- by Ensuring
- by ArrowAssoc
- Hide All
- Show All
- Public
- All
Instance Constructors
Value Members
-
def
build(): EventHandler[State, Event]
Builds and returns a handler from the appended states.
Builds and returns a handler from the appended states. The returned EventHandler will throw a scala.MatchError if applied to an event that has no defined case.
-
def
matchAny(handler: Function[Event, State]): EventHandler[State, Event]
Match any event.
Match any event.
Use this when then
State
is not needed in thehandler
, otherwise there is an overloaded method that pass the state in aBiFunction
.Note: event handlers are matched in the order they are added. Once a matching is found, it's selected for handling the event 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 event handlers.
Extra care should be taken when using matchAny as it will match any event. This method builds and returns the event handler since this will not let through any states to subsequent match statements.
- returns
An EventHandler from the appended states.
-
def
matchAny(handler: BiFunction[State, Event, State]): EventHandler[State, Event]
Match any event.
Match any event.
Note: event handlers are matched in the order they are added. Once a matching is found, it's selected for handling the event 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 event handlers.
Extra care should be taken when using matchAny as it will match any event. This method builds and returns the event handler since this will not let through any states to subsequent match statements.
- returns
An EventHandler from the appended states.
-
def
matchEvent[E <: Event](eventClass: Class[E], handler: Supplier[State]): EventHandlerBuilderByState[S, State, Event]
Match any event which is an instance of
E
or a subtype ofE
.Match any event which is an instance of
E
or a subtype ofE
.Use this when then
State
and theEvent
are not needed in thehandler
.Note: event handlers are matched in the order they are added. Once a matching is found, it's selected for handling the event 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 event handlers.
-
def
matchEvent[E <: Event](eventClass: Class[E], handler: Function[E, State]): EventHandlerBuilderByState[S, State, Event]
Match any event which is an instance of
E
or a subtype ofE
.Match any event which is an instance of
E
or a subtype ofE
.Use this when then
State
is not needed in thehandler
, otherwise there is an overloaded method that pass the state in aBiFunction
.Note: event handlers are matched in the order they are added. Once a matching is found, it's selected for handling the event 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 event handlers.
-
def
matchEvent[E <: Event](eventClass: Class[E], handler: BiFunction[S, E, State]): EventHandlerBuilderByState[S, State, Event]
Match any event which is an instance of
E
or a subtype ofE
.Match any event which is an instance of
E
or a subtype ofE
.Note: event handlers are matched in the order they are added. Once a matching is found, it's selected for handling the event 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 event handlers.
-
def
orElse[S2 <: State](other: EventHandlerBuilderByState[S2, State, Event]): EventHandlerBuilderByState[S2, State, Event]
Compose this builder with another builder.
Compose this builder with another builder. The handlers in this builder will be tried first followed by the handlers in
other
.