Package akka.japi.pf
Class PFBuilder<I,R>
- java.lang.Object
-
- akka.japi.pf.PFBuilder<I,R>
-
- Type Parameters:
I
- the input type, that this PartialFunction will be applied toR
- the return type, that the results of the application will have
public final class PFBuilder<I,R> extends java.lang.Object
A builder forPartialFunction
.
-
-
Constructor Summary
Constructors Constructor Description PFBuilder()
Create a PFBuilder.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addStatement(scala.PartialFunction<F,T> statement)
scala.PartialFunction<F,T>
build()
Build aPartialFunction
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<I,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.PFBuilder<I,R>
matchUnchecked(java.lang.Class<?> type, FI.Apply<?,R> apply)
Add a new case statement to this builder without compile time type check of the parameters.PFBuilder<I,R>
matchUnchecked(java.lang.Class<?> type, FI.TypedPredicate<?> predicate, FI.Apply<?,R> apply)
Add a new case statement to this builder without compile time type check of the parameters.
-
-
-
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 againstapply
- an action to apply to the argument if the type matches- Returns:
- a builder with the case statement added
-
matchUnchecked
public PFBuilder<I,R> matchUnchecked(java.lang.Class<?> type, FI.Apply<?,R> apply)
Add a new case statement to this builder without compile time type check of the parameters. Should normally not be used, but when matching on class with generic type argument it can be useful, e.g.List.class
and(List<String> list) -> {}
.- Parameters:
type
- a type to match the argument againstapply
- 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 againstpredicate
- a predicate that will be evaluated on the argument if the type matchesapply
- an action to apply to the argument if the type matches and the predicate returns true- Returns:
- a builder with the case statement added
-
matchUnchecked
public PFBuilder<I,R> matchUnchecked(java.lang.Class<?> type, FI.TypedPredicate<?> predicate, FI.Apply<?,R> apply)
Add a new case statement to this builder without compile time type check of the parameters. Should normally not be used, but when matching on class with generic type argument it can be useful, e.g.List.class
and(List<String> list) -> {}
.- Parameters:
type
- a type to match the argument againstpredicate
- a predicate that will be evaluated on the argument if the type matchesapply
- 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 withapply
- 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<I,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 aPartialFunction
from this builder. After this call the builder will be reset.- Returns:
- a PartialFunction for this builder.
-
-