Class Behavior<T>

    • Constructor Detail

      • Behavior

        public Behavior​(int _tag)
    • Method Detail

      • canonicalize

        public static <T> Behavior<T> canonicalize​(Behavior<T> behavior,
                                                   Behavior<T> current,
                                                   TypedActorContext<T> ctx)
        Given a possibly special behavior (same or unhandled) and a &ldquo;current&rdquo; behavior (which defines the meaning of encountering a same behavior) this method computes the next behavior, suitable for passing a message or signal.
      • 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.
      • 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 an IllegalArgumentException will be thrown.
      • 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 be same nor unhandled. Starting out with a Stopped behavior is allowed, though.
      • isAlive

        public static <T> boolean isAlive​(Behavior<T> behavior)
        Returns true if the given behavior is not stopped.
      • isUnhandled

        public static <T> boolean isUnhandled​(Behavior<T> behavior)
        Returns true if the given behavior is the special unhandled marker.
      • isDeferred

        public static <T> boolean isDeferred​(Behavior<T> behavior)
        Returns true if the given behavior is deferred.
      • interpretMessage

        public static <T> Behavior<T> interpretMessage​(Behavior<T> behavior,
                                                       TypedActorContext<T> ctx,
                                                       T msg)
        Execute the behavior with the given message.
      • _tag

        public int _tag()
      • narrow

        public final <U extends TBehavior<U> narrow()
        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).
      • unsafeCast

        public final <U> Behavior<U> unsafeCast()

        Unsafe 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 from Nothing to some type U. Use it with caution, it may lead to a ClassCastException when you send a message to the resulting {@link Behavior[U}].