akka.japi.pf
Class ReceiveBuilder

java.lang.Object
  extended by akka.japi.pf.ReceiveBuilder

public class ReceiveBuilder
extends java.lang.Object

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:


Method Summary
static
<P> UnitPFBuilder<java.lang.Object>
match(java.lang.Class<P> type, FI.TypedPredicate<P> predicate, FI.UnitApply<P> apply)
          Return a new UnitPFBuilder with a case statement added.
static
<P> UnitPFBuilder<java.lang.Object>
match(java.lang.Class<P> type, FI.UnitApply<P> apply)
          Return a new UnitPFBuilder with a case statement added.
static UnitPFBuilder<java.lang.Object> matchAny(FI.UnitApply<java.lang.Object> apply)
          Return a new UnitPFBuilder with a case statement added.
static
<P> UnitPFBuilder<java.lang.Object>
matchEquals(P object, FI.TypedPredicate<P> predicate, FI.UnitApply<P> apply)
          Return a new UnitPFBuilder with a case statement added.
static
<P> UnitPFBuilder<java.lang.Object>
matchEquals(P object, FI.UnitApply<P> apply)
          Return a new UnitPFBuilder with a case statement added.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

match

public static <P> UnitPFBuilder<java.lang.Object> match(java.lang.Class<P> type,
                                                        FI.UnitApply<P> apply)
Return a new UnitPFBuilder with a case statement added.

Parameters:
type - a type to match the argument against
apply - an action to apply to the argument if the type matches
Returns:
a builder with the case statement added

match

public static <P> UnitPFBuilder<java.lang.Object> match(java.lang.Class<P> type,
                                                        FI.TypedPredicate<P> predicate,
                                                        FI.UnitApply<P> apply)
Return a new UnitPFBuilder with a case statement added.

Parameters:
type - a type to match the argument against
predicate - a predicate that will be evaluated on the argument if the type matches
apply - an action to apply to the argument if the type matches and the predicate returns true
Returns:
a builder with the case statement added

matchEquals

public static <P> UnitPFBuilder<java.lang.Object> matchEquals(P object,
                                                              FI.UnitApply<P> apply)
Return a new UnitPFBuilder with a case statement added.

Parameters:
object - the object to compare equals with
apply - an action to apply to the argument if the object compares equal
Returns:
a builder with the case statement added

matchEquals

public static <P> UnitPFBuilder<java.lang.Object> matchEquals(P object,
                                                              FI.TypedPredicate<P> predicate,
                                                              FI.UnitApply<P> apply)
Return a new UnitPFBuilder with a case statement added.

Parameters:
object - the object to compare equals with
predicate - a predicate that will be evaluated on the argument if the object compares equal
apply - an action to apply to the argument if the object compares equal
Returns:
a builder with the case statement added

matchAny

public static UnitPFBuilder<java.lang.Object> matchAny(FI.UnitApply<java.lang.Object> apply)
Return a new UnitPFBuilder with a case statement added.

Parameters:
apply - an action to apply to the argument
Returns:
a builder with the case statement added