c

akka.japi.pf

ReceiveBuilder

class ReceiveBuilder extends AnyRef

Used for building a partial function for Actor.receive().

There is both a match on type only, and a match on type and predicate.

Inside an actor you can use it like this with Java 8 to define your receive method.

Example:

@Override
public Actor() {
  receive(ReceiveBuilder.
    match(Double.class, d -> {
      sender().tell(d.isNaN() ? 0 : d, self());
    }).
    match(Integer.class, i -> {
      sender().tell(i * 10, self());
    }).
    match(String.class, s -> s.startsWith("foo"), s -> {
      sender().tell(s.toUpperCase(), self());
    }).build()
  );
}

This is an EXPERIMENTAL feature and is subject to change until it has received more real world testing.

Source
ReceiveBuilder.java
Linear Supertypes
Type Hierarchy
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. ReceiveBuilder
  2. AnyRef
  3. Any
Implicitly
  1. by any2stringadd
  2. by StringFormat
  3. by Ensuring
  4. by ArrowAssoc
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All