Package org.apache.pekko.actor.typed
Class Behavior.BehaviorDecorators<Inner>
java.lang.Object
scala.AnyVal
org.apache.pekko.actor.typed.Behavior.BehaviorDecorators<Inner>
public static final class Behavior.BehaviorDecorators<Inner>
extends scala.AnyVal
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbehavior()booleaninthashCode()<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 wrappedBehavior: 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.
-
Constructor Details
-
BehaviorDecorators
-
-
Method Details
-
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 wrappedBehavior: 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:
val b: Behavior[Number] = Behaviors .receive[String] { (ctx, msg) => println(msg) Behaviors.same } .transformMessages[Number] { case b: BigDecimal => s"BigDecimal($b)" case i: BigInt => s"BigInteger($i)" // all other kinds of Number will be `unhandled` }The
ClassTagforOuterensures 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() -
equals
-