I
- the input type, that this PartialFunction will be applied toR
- 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
PartialFunction
.Modifier and Type | Field and Description |
---|---|
protected scala.PartialFunction<F,T> |
statements |
Constructor and Description |
---|
PFBuilder()
Create a PFBuilder.
|
Modifier and Type | Method and Description |
---|---|
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<? extends P> type,
FI.Apply<? extends P,R> apply)
Add a new case statement to this builder.
|
<P> PFBuilder<I,R> |
match(java.lang.Class<? extends P> type,
FI.TypedPredicate<? extends P> predicate,
FI.Apply<? extends 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.
|
public <P> PFBuilder<I,R> match(java.lang.Class<? extends P> type, FI.Apply<? extends P,R> apply)
type
- a type to match the argument againstapply
- an action to apply to the argument if the type matchespublic <P> PFBuilder<I,R> match(java.lang.Class<? extends P> type, FI.TypedPredicate<? extends P> predicate, FI.Apply<? extends P,R> apply)
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 truepublic <P> PFBuilder<I,R> matchEquals(P object, FI.Apply<P,R> apply)
object
- the object to compare equals withapply
- an action to apply to the argument if the object compares equalpublic PFBuilder<I,R> matchAny(FI.Apply<I,R> apply)
apply
- an action to apply to the argumentprotected void addStatement(scala.PartialFunction<F,T> statement)
public scala.PartialFunction<F,T> build()
PartialFunction
from this builder.
After this call the builder will be reset.