Package akka.actor.typed
Class Behavior$
- java.lang.Object
-
- akka.actor.typed.Behavior$
-
public class Behavior$ extends java.lang.Object
Widen the wrapped Behavior by placing a funnel in front of it: the supplied PartialFunction decides which message to pull in (those that it is defined at) and may transform the incoming message to place them into the wrapped Behavior’s type hierarchy. Signals are not transformed.Example:
receive[String] { (ctx, msg) => println(msg); same }.widen[Number] { case b: BigDecimal => s"BigDecimal($b)" case i: BigInteger => s"BigInteger($i)" // all other kinds of Number will be `unhandled` }
Scheduled messages via
TimerScheduler
can currently not be used together withwiden
, see issue #25318.
-
-
Constructor Summary
Constructors Constructor Description Behavior$()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> Behavior.BehaviorDecorators<T>
BehaviorDecorators(Behavior<T> behavior)
<T> Behavior<T>
canonicalize(Behavior<T> behavior, Behavior<T> current, TypedActorContext<T> ctx)
<T> Behavior<T>
empty()
A behavior that treats every incoming message as unhandled.<T> boolean
existsInStack(Behavior<T> behavior, scala.Function1<Behavior<T>,java.lang.Object> p)
Go through the behavior stack and apply a predicate to see if any nested behavior satisfies it.<T> Behavior<T>
failed(java.lang.Throwable cause)
<T> Behavior<T>
ignore()
A behavior that ignores every incoming message and returns “same”.<T> Behavior<T>
interpretMessage(Behavior<T> behavior, TypedActorContext<T> ctx, T msg)
Execute the behavior with the given message<T> Behavior<T>
interpretSignal(Behavior<T> behavior, TypedActorContext<T> ctx, Signal signal)
Execute the behavior with the given signal<T> boolean
isAlive(Behavior<T> behavior)
Returns true if the given behavior is not stopped.<T> boolean
isDeferred(Behavior<T> behavior)
Returns true if the given behavior is the specialUnhandled
marker.<T> boolean
isUnhandled(Behavior<T> behavior)
Returns true if the given behavior is the specialunhandled
marker.<T> Behavior<T>
same()
<T> Behavior<T>
start(Behavior<T> behavior, TypedActorContext<T> ctx)
Starts deferred behavior and nested deferred behaviors until all deferred behaviors in the stack are started and then the resulting behavior is returned.<T> Behavior<T>
stopped()
Return this behavior from message processing to signal that this actor shall terminate voluntarily.<T> Behavior<T>
stopped(scala.Function0<scala.runtime.BoxedUnit> postStop)
Return this behavior from message processing to signal that this actor shall terminate voluntarily.<T> Behavior<T>
unhandled()
Return this behavior from message processing in order to advise the system to reuse the previous behavior, including the hint that the message has not been handled.scala.PartialFunction<scala.Tuple2<TypedActorContext<scala.runtime.Nothing$>,Signal>,Behavior<scala.runtime.Nothing$>>
unhandledSignal()
INTERNAL API<T> Behavior<T>
validateAsInitial(Behavior<T> behavior)
Validate the given behavior as a suitable initial actor behavior; most notably the behavior can neither besame
norunhandled
.
-
-
-
Field Detail
-
MODULE$
public static final Behavior$ MODULE$
Static reference to the singleton instance of this Scala object.
-
-
Method Detail
-
BehaviorDecorators
public <T> Behavior.BehaviorDecorators<T> BehaviorDecorators(Behavior<T> behavior)
-
same
public <T> Behavior<T> same()
-
unhandled
public <T> Behavior<T> unhandled()
Return this behavior from message processing in order to advise the system to reuse the previous behavior, including the hint that the message has not been handled. This hint may be used by composite behaviors that delegate (partial) handling to other behaviors.- Returns:
- (undocumented)
-
stopped
public <T> Behavior<T> stopped()
Return this behavior from message processing to signal that this actor shall terminate voluntarily. If this actor has created child actors then these will be stopped as part of the shutdown procedure.The PostStop signal that results from stopping this actor will be passed to the current behavior. All other messages and signals will effectively be ignored.
- Returns:
- (undocumented)
-
stopped
public <T> Behavior<T> stopped(scala.Function0<scala.runtime.BoxedUnit> postStop)
Return this behavior from message processing to signal that this actor shall terminate voluntarily. If this actor has created child actors then these will be stopped as part of the shutdown procedure.The PostStop signal that results from stopping this actor will be passed to the given
postStop
behavior. All other messages and signals will effectively be ignored.- Parameters:
postStop
- (undocumented)- Returns:
- (undocumented)
-
empty
public <T> Behavior<T> empty()
A behavior that treats every incoming message as unhandled.- Returns:
- (undocumented)
-
ignore
public <T> Behavior<T> ignore()
A behavior that ignores every incoming message and returns “same”.- Returns:
- (undocumented)
-
failed
public <T> Behavior<T> failed(java.lang.Throwable cause)
-
unhandledSignal
public scala.PartialFunction<scala.Tuple2<TypedActorContext<scala.runtime.Nothing$>,Signal>,Behavior<scala.runtime.Nothing$>> unhandledSignal()
INTERNAL API- Returns:
- (undocumented)
-
canonicalize
public <T> Behavior<T> canonicalize(Behavior<T> behavior, Behavior<T> current, TypedActorContext<T> ctx)
-
start
public <T> Behavior<T> start(Behavior<T> behavior, TypedActorContext<T> ctx)
Starts deferred behavior and nested deferred behaviors until all deferred behaviors in the stack are started and then the resulting behavior is returned.- Parameters:
behavior
- (undocumented)ctx
- (undocumented)- Returns:
- (undocumented)
-
existsInStack
public <T> boolean existsInStack(Behavior<T> behavior, scala.Function1<Behavior<T>,java.lang.Object> p)
Go through the behavior stack and apply a predicate to see if any nested behavior satisfies it. The stack must not contain any unstarted deferred behavior or anIllegalArgumentException
will be thrown.- Parameters:
behavior
- (undocumented)p
- (undocumented)- Returns:
- (undocumented)
-
validateAsInitial
public <T> Behavior<T> validateAsInitial(Behavior<T> behavior)
Validate the given behavior as a suitable initial actor behavior; most notably the behavior can neither besame
norunhandled
. Starting out with aStopped
behavior is allowed, though.- Parameters:
behavior
- (undocumented)- Returns:
- (undocumented)
-
isAlive
public <T> boolean isAlive(Behavior<T> behavior)
Returns true if the given behavior is not stopped.- Parameters:
behavior
- (undocumented)- Returns:
- (undocumented)
-
isUnhandled
public <T> boolean isUnhandled(Behavior<T> behavior)
Returns true if the given behavior is the specialunhandled
marker.- Parameters:
behavior
- (undocumented)- Returns:
- (undocumented)
-
isDeferred
public <T> boolean isDeferred(Behavior<T> behavior)
Returns true if the given behavior is the specialUnhandled
marker.- Parameters:
behavior
- (undocumented)- Returns:
- (undocumented)
-
interpretMessage
public <T> Behavior<T> interpretMessage(Behavior<T> behavior, TypedActorContext<T> ctx, T msg)
Execute the behavior with the given message- Parameters:
behavior
- (undocumented)ctx
- (undocumented)msg
- (undocumented)- Returns:
- (undocumented)
-
interpretSignal
public <T> Behavior<T> interpretSignal(Behavior<T> behavior, TypedActorContext<T> ctx, Signal signal)
Execute the behavior with the given signal- Parameters:
behavior
- (undocumented)ctx
- (undocumented)signal
- (undocumented)- Returns:
- (undocumented)
-
-