public final class EventHandlerBuilder<Event,State>
extends java.lang.Object
| Constructor and Description |
|---|
EventHandlerBuilder(java.lang.Class<Event> rootEventClass) |
| Modifier and Type | Method and Description |
|---|---|
EventHandler<Event,State> |
build()
Builds and returns a handler from the appended states.
|
EventHandler<Event,State> |
matchAny(java.util.function.BiFunction<State,Event,State> biFunction)
Match any event
|
<E extends Event> |
matchEvent(java.lang.Class<E> eventClass,
java.util.function.BiFunction<State,E,State> biFunction)
Match any event which is an instance of
E or a subtype of E |
public EventHandlerBuilder(java.lang.Class<Event> rootEventClass)
public EventHandler<Event,State> build()
EventHandler will throw a MatchError
if applied to an event that has no defined case.
The builder is reset to empty after build has been called.
public EventHandler<Event,State> matchAny(java.util.function.BiFunction<State,Event,State> biFunction)
Builds and returns the handler since this will not let through any states to subsequent match statements
biFunction - (undocumented)public <E extends Event> EventHandlerBuilder<Event,State> matchEvent(java.lang.Class<E> eventClass, java.util.function.BiFunction<State,E,State> biFunction)
E or a subtype of E
Throws java.lang.IllegalArgumentException if eventClass is not a subtype of the root Event this builder was created with
eventClass - (undocumented)biFunction - (undocumented)