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 class Match<I,R>
extends java.lang.Object
PartialFunction
that can be built during
runtime from Java.Modifier and Type | Field and Description |
---|---|
protected scala.PartialFunction<I,R> |
statements |
Modifier and Type | Method and Description |
---|---|
scala.PartialFunction<I,R> |
asPF()
Turn this
Match into a PartialFunction . |
static <F,T> Match<F,T> |
create(PFBuilder<F,T> builder)
Create a
Match from the builder. |
static <F,T,P> PFBuilder<F,T> |
match(java.lang.Class<? extends P> type,
FI.Apply<? extends P,T> apply)
Convenience function to create a
PFBuilder with the first
case statement added. |
static <F,T,P> PFBuilder<F,T> |
match(java.lang.Class<? extends P> type,
FI.TypedPredicate<? extends P> predicate,
FI.Apply<? extends P,T> apply)
Convenience function to create a
PFBuilder with the first
case statement added. |
R |
match(I i)
Convenience function to make the Java code more readable.
|
static <F,T> PFBuilder<F,T> |
matchAny(FI.Apply<F,T> apply)
Convenience function to create a
PFBuilder with the first
case statement added. |
static <F,T,P> PFBuilder<F,T> |
matchEquals(P object,
FI.Apply<P,T> apply)
Convenience function to create a
PFBuilder with the first
case statement added. |
public static <F,T,P> PFBuilder<F,T> match(java.lang.Class<? extends P> type, FI.Apply<? extends P,T> apply)
PFBuilder
with the first
case statement added.type
- a type to match the argument againstapply
- an action to apply to the argument if the type matchesPFBuilder.match(Class, FI.Apply)
public static <F,T,P> PFBuilder<F,T> match(java.lang.Class<? extends P> type, FI.TypedPredicate<? extends P> predicate, FI.Apply<? extends P,T> apply)
PFBuilder
with the first
case statement added.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 matchesPFBuilder.match(Class, FI.TypedPredicate, FI.Apply)
public static <F,T,P> PFBuilder<F,T> matchEquals(P object, FI.Apply<P,T> apply)
PFBuilder
with the first
case statement added.object
- the object to compare equals withapply
- an action to apply to the argument if the object compares equalPFBuilder.matchEquals(Object, FI.Apply)
public static <F,T> PFBuilder<F,T> matchAny(FI.Apply<F,T> apply)
PFBuilder
with the first
case statement added.apply
- an action to apply to the argumentPFBuilder.matchAny(FI.Apply)
public static final <F,T> Match<F,T> create(PFBuilder<F,T> builder)
Match
from the builder.builder
- a builder representing the partial functionMatch
that can be reusedpublic R match(I i) throws scala.MatchError
Matcher<X, Y> matcher = Matcher.create(...);
Y someY = matcher.match(obj);
i
- the argument to apply the match toscala.MatchError
- if there is no match