Package akka.actor.typed
Class Behavior<T>
- java.lang.Object
-
- akka.actor.typed.Behavior<T>
-
- Direct Known Subclasses:
BehaviorImpl.DeferredBehavior
,BehaviorImpl.FailedBehavior
,BehaviorImpl.SameBehavior$
,BehaviorImpl.StoppedBehavior
,BehaviorImpl.UnhandledBehavior$
,ExtensibleBehavior
public abstract class Behavior<T> extends java.lang.Object
Narrow the type of this Behavior, which is always a safe operation. This method is necessary to implement the contravariant nature of Behavior (which cannot be expressed directly due to type inference problems).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Behavior.BehaviorDecorators<Inner>
static class
Behavior.BehaviorDecorators$
-
Constructor Summary
Constructors Constructor Description Behavior(int _tag)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
_tag()
static <Inner> Behavior.BehaviorDecorators<Inner>
BehaviorDecorators(Behavior<Inner> behavior)
static <T> Behavior<T>
canonicalize(Behavior<T> behavior, Behavior<T> current, TypedActorContext<T> ctx)
static <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.static <T> Behavior<T>
interpretMessage(Behavior<T> behavior, TypedActorContext<T> ctx, T msg)
Execute the behavior with the given messagestatic <T> Behavior<T>
interpretSignal(Behavior<T> behavior, TypedActorContext<T> ctx, Signal signal)
Execute the behavior with the given signalstatic <T> boolean
isAlive(Behavior<T> behavior)
Returns true if the given behavior is not stopped.static <T> boolean
isDeferred(Behavior<T> behavior)
Returns true if the given behavior is the specialUnhandled
marker.static <T> boolean
isUnhandled(Behavior<T> behavior)
Returns true if the given behavior is the specialunhandled
marker.<U extends T>
Behavior<U>narrow()
static <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.<U> Behavior<U>
unsafeCast()
INTERNAL APIstatic <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
.
-
-
-
Method Detail
-
BehaviorDecorators
public static final <Inner> Behavior.BehaviorDecorators<Inner> BehaviorDecorators(Behavior<Inner> behavior)
-
canonicalize
public static <T> Behavior<T> canonicalize(Behavior<T> behavior, Behavior<T> current, TypedActorContext<T> ctx)
-
start
public static <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 static <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 static <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 static <T> boolean isAlive(Behavior<T> behavior)
Returns true if the given behavior is not stopped.- Parameters:
behavior
- (undocumented)- Returns:
- (undocumented)
-
isUnhandled
public static <T> boolean isUnhandled(Behavior<T> behavior)
Returns true if the given behavior is the specialunhandled
marker.- Parameters:
behavior
- (undocumented)- Returns:
- (undocumented)
-
isDeferred
public static <T> boolean isDeferred(Behavior<T> behavior)
Returns true if the given behavior is the specialUnhandled
marker.- Parameters:
behavior
- (undocumented)- Returns:
- (undocumented)
-
interpretMessage
public static <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 static <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)
-
_tag
public int _tag()
-
unsafeCast
public final <U> Behavior<U> unsafeCast()
INTERNAL APIUnsafe utility method for changing the type accepted by this Behavior; provided as an alternative to the universally available
asInstanceOf
, which casts the entire type rather than just the type parameter. Typically used to upcast a type, for instance fromNothing
to some typeU
. Use it with caution, it may lead to aClassCastException
when you send a message to the resulting {@link Behavior[U}].- Returns:
- (undocumented)
-
-