Package akka.actor.typed.javadsl
Class BehaviorBuilder<T>
- java.lang.Object
-
- akka.actor.typed.javadsl.BehaviorBuilder<T>
-
public final class BehaviorBuilder<T> extends java.lang.Object
Build a Behavior from the current state of the builder
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
BehaviorBuilder.Case<BT,MT>
INTERNAL APIstatic class
BehaviorBuilder.Case$
-
Constructor Summary
Constructors Constructor Description BehaviorBuilder()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Behavior<T>
build()
static <T> BehaviorBuilder<T>
create()
BehaviorBuilder<T>
onAnyMessage(Function2<ActorContext<T>,T,Behavior<T>> handler)
Add a new case to the message handling matching any message.<M extends T>
BehaviorBuilder<T>onMessage(java.lang.Class<M> type, Function2<ActorContext<T>,M,Behavior<T>> handler)
Add a new case to the message handling.<M extends T>
BehaviorBuilder<T>onMessage(java.lang.Class<M> type, Predicate<M> test, Function2<ActorContext<T>,M,Behavior<T>> handler)
Add a new predicated case to the message handling.BehaviorBuilder<T>
onMessageEquals(T msg, Function<ActorContext<T>,Behavior<T>> handler)
Add a new case to the message handling matching equal messages.<M extends T>
BehaviorBuilder<T>onMessageUnchecked(java.lang.Class<? extends T> type, Function2<ActorContext<T>,M,Behavior<T>> handler)
Add a new case to the message handling without compile time type check.<M extends Signal>
BehaviorBuilder<T>onSignal(java.lang.Class<M> type, Function2<ActorContext<T>,M,Behavior<T>> handler)
Add a new case to the signal handling.<M extends Signal>
BehaviorBuilder<T>onSignal(java.lang.Class<M> type, Predicate<M> test, Function2<ActorContext<T>,M,Behavior<T>> handler)
Add a new predicated case to the signal handling.BehaviorBuilder<T>
onSignalEquals(Signal signal, scala.Function1<ActorContext<T>,Behavior<T>> handler)
Add a new case to the signal handling matching equal signals.
-
-
-
Method Detail
-
create
public static <T> BehaviorBuilder<T> create()
-
onMessage
public <M extends T> BehaviorBuilder<T> onMessage(java.lang.Class<M> type, Function2<ActorContext<T>,M,Behavior<T>> handler)
Add a new case to the message handling.- Parameters:
type
- type of message to matchhandler
- action to apply if the type matches- Returns:
- a new behavior builder with the specified handling appended
-
onMessage
public <M extends T> BehaviorBuilder<T> onMessage(java.lang.Class<M> type, Predicate<M> test, Function2<ActorContext<T>,M,Behavior<T>> handler)
Add a new predicated case to the message handling.- Parameters:
type
- type of message to matchtest
- a predicate that will be evaluated on the argument if the type matcheshandler
- action to apply if the type matches and the predicate returns true- Returns:
- a new behavior builder with the specified handling appended
-
onMessageUnchecked
public <M extends T> BehaviorBuilder<T> onMessageUnchecked(java.lang.Class<? extends T> type, Function2<ActorContext<T>,M,Behavior<T>> handler)
Add a new case to the message handling without compile time type check.Should normally not be used, but when matching on class with generic type argument it can be useful, e.g.
List.class
and(List<String> list) -> {...}
- Parameters:
type
- type of message to matchhandler
- action to apply when the type matches- Returns:
- a new behavior builder with the specified handling appended
-
onMessageEquals
public BehaviorBuilder<T> onMessageEquals(T msg, Function<ActorContext<T>,Behavior<T>> handler)
Add a new case to the message handling matching equal messages.- Parameters:
msg
- the message to compare tohandler
- action to apply when the message matches- Returns:
- a new behavior builder with the specified handling appended
-
onAnyMessage
public BehaviorBuilder<T> onAnyMessage(Function2<ActorContext<T>,T,Behavior<T>> handler)
Add a new case to the message handling matching any message. SubsequentonMessage
clauses will never see any messages.- Parameters:
handler
- action to apply for any message- Returns:
- a new behavior builder with the specified handling appended
-
onSignal
public <M extends Signal> BehaviorBuilder<T> onSignal(java.lang.Class<M> type, Function2<ActorContext<T>,M,Behavior<T>> handler)
Add a new case to the signal handling.- Parameters:
type
- type of signal to matchhandler
- action to apply if the type matches- Returns:
- a new behavior builder with the specified handling appended
-
onSignal
public <M extends Signal> BehaviorBuilder<T> onSignal(java.lang.Class<M> type, Predicate<M> test, Function2<ActorContext<T>,M,Behavior<T>> handler)
Add a new predicated case to the signal handling.- Parameters:
type
- type of signals to matchtest
- a predicate that will be evaluated on the argument if the type matcheshandler
- action to apply if the type matches and the predicate returns true- Returns:
- a new behavior builder with the specified handling appended
-
onSignalEquals
public BehaviorBuilder<T> onSignalEquals(Signal signal, scala.Function1<ActorContext<T>,Behavior<T>> handler)
Add a new case to the signal handling matching equal signals.- Parameters:
signal
- the signal to compare tohandler
- action to apply when the message matches- Returns:
- a new behavior builder with the specified handling appended
-
-