Class Behavior.BehaviorDecorators<Inner>

java.lang.Object
scala.AnyVal
org.apache.pekko.actor.typed.Behavior.BehaviorDecorators<Inner>
Enclosing class:
Behavior<T>

public static final class Behavior.BehaviorDecorators<Inner> extends scala.AnyVal
  • Constructor Details

    • BehaviorDecorators

      public BehaviorDecorators(Behavior<Inner> behavior)
  • Method Details

    • behavior

      public Behavior<Inner> behavior()
    • transformMessages

      public <Outer> Behavior<Outer> transformMessages(scala.PartialFunction<Outer,Inner> matcher, scala.reflect.ClassTag<Outer> evidence$1)
      Transform the incoming messages by placing a funnel in front of the wrapped Behavior: 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&rsquo;s type hierarchy. Signals are not transformed.

      Example:

      
         val b: Behavior[Number] =
           Behaviors
             .receive[String] { (ctx, msg) =>
               println(msg)
               Behaviors.same
             }
             .transformMessages[Number] {
               case b: BigDecimal => s"BigDecimal(&dollar;b)"
               case i: BigInt     => s"BigInteger(&dollar;i)"
               // all other kinds of Number will be `unhandled`
             }
       

      The ClassTag for Outer ensures that only messages of this class or a subclass thereof will be intercepted. Other message types (e.g. a private protocol) will bypass the interceptor and be continue to the inner behavior untouched.

    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object x$1)
      Overrides:
      equals in class Object