akka.japi.pf
Class PFBuilder<I,R>

java.lang.Object
  extended by akka.japi.pf.PFBuilder<I,R>
Type Parameters:
I - the input type, that this PartialFunction will be applied to
R - the return type, that the results of the application will have This is an EXPERIMENTAL feature and is subject to change until it has received more real world testing.

public final class PFBuilder<I,R>
extends java.lang.Object

A builder for PartialFunction.


Field Summary
protected  scala.PartialFunction<F,T> statements
           
 
Constructor Summary
PFBuilder()
          Create a PFBuilder.
 
Method Summary
protected  void addStatement(scala.PartialFunction<F,T> statement)
           
 scala.PartialFunction<F,T> build()
          Build a PartialFunction from this builder.
<P> PFBuilder<I,R>
match(java.lang.Class<P> type, FI.Apply<P,R> apply)
          Add a new case statement to this builder.
<P> PFBuilder<I,R>
match(java.lang.Class<P> type, FI.TypedPredicate<P> predicate, FI.Apply<P,R> apply)
          Add a new case statement to this builder.
 PFBuilder<I,R> matchAny(FI.Apply<java.lang.Object,R> apply)
          Add a new case statement to this builder, that matches any argument.
<P> PFBuilder<I,R>
matchEquals(P object, FI.Apply<P,R> apply)
          Add a new case statement to this builder.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

statements

protected scala.PartialFunction<F,T> statements
Constructor Detail

PFBuilder

public PFBuilder()
Create a PFBuilder.

Method Detail

match

public <P> PFBuilder<I,R> match(java.lang.Class<P> type,
                                FI.Apply<P,R> apply)
Add a new case statement to this builder.

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 <P> PFBuilder<I,R> match(java.lang.Class<P> type,
                                FI.TypedPredicate<P> predicate,
                                FI.Apply<P,R> apply)
Add a new case statement to this builder.

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 <P> PFBuilder<I,R> matchEquals(P object,
                                      FI.Apply<P,R> apply)
Add a new case statement to this builder.

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

matchAny

public PFBuilder<I,R> matchAny(FI.Apply<java.lang.Object,R> apply)
Add a new case statement to this builder, that matches any argument.

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

addStatement

protected void addStatement(scala.PartialFunction<F,T> statement)

build

public scala.PartialFunction<F,T> build()
Build a PartialFunction from this builder. After this call the builder will be reset.

Returns:
a PartialFunction for this builder.