I
- the input type, that this PartialFunction will be applied to
This is an EXPERIMENTAL feature and is subject to change until it has received more real world testing.public class UnitMatch<I>
extends java.lang.Object
PartialFunction
that can be built during
runtime from Java.
This is a specialized version of UnitMatch
to map java
void methods to BoxedUnit
.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> UnitMatch<F> |
create(UnitPFBuilder<F> builder)
Create a
UnitMatch from the builder. |
static <F,P> UnitPFBuilder<F> |
match(java.lang.Class<? extends P> type,
FI.TypedPredicate<? extends P> predicate,
FI.UnitApply<? extends P> apply)
Convenience function to create a
UnitPFBuilder with the first
case statement added. |
static <F,P> UnitPFBuilder<F> |
match(java.lang.Class<? extends P> type,
FI.UnitApply<? extends P> apply)
Convenience function to create a
UnitPFBuilder with the first
case statement added. |
void |
match(I i)
Convenience function to make the Java code more readable.
|
static <F> UnitPFBuilder<F> |
matchAny(FI.UnitApply<java.lang.Object> apply)
Convenience function to create a
UnitPFBuilder with the first
case statement added. |
static <F,P> UnitPFBuilder<F> |
matchEquals(P object,
FI.TypedPredicate<P> predicate,
FI.UnitApply<P> apply)
Convenience function to create a
UnitPFBuilder with the first
case statement added. |
static <F,P> UnitPFBuilder<F> |
matchEquals(P object,
FI.UnitApply<P> apply)
Convenience function to create a
UnitPFBuilder with the first
case statement added. |
public static <F,P> UnitPFBuilder<F> match(java.lang.Class<? extends P> type, FI.UnitApply<? extends P> apply)
UnitPFBuilder
with the first
case statement added.type
- a type to match the argument againstapply
- an action to apply to the argument if the type matchesUnitPFBuilder.match(Class, FI.UnitApply)
public static <F,P> UnitPFBuilder<F> match(java.lang.Class<? extends P> type, FI.TypedPredicate<? extends P> predicate, FI.UnitApply<? extends P> apply)
UnitPFBuilder
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 and predicate matchesUnitPFBuilder.match(Class, FI.TypedPredicate, FI.UnitApply)
public static <F,P> UnitPFBuilder<F> matchEquals(P object, FI.UnitApply<P> apply)
UnitPFBuilder
with the first
case statement added.object
- the object to compare equals withapply
- an action to apply to the argument if the object compares equalUnitPFBuilder.matchEquals(Object, FI.UnitApply)
public static <F,P> UnitPFBuilder<F> matchEquals(P object, FI.TypedPredicate<P> predicate, FI.UnitApply<P> apply)
UnitPFBuilder
with the first
case statement added.object
- the object to compare equals withpredicate
- a predicate that will be evaluated on the argument the object compares equalapply
- an action to apply to the argument if the object compares equalUnitPFBuilder.matchEquals(Object, FI.UnitApply)
public static <F> UnitPFBuilder<F> matchAny(FI.UnitApply<java.lang.Object> apply)
UnitPFBuilder
with the first
case statement added.apply
- an action to apply to the argumentUnitPFBuilder.matchAny(FI.UnitApply)
public static <F> UnitMatch<F> create(UnitPFBuilder<F> builder)
UnitMatch
from the builder.builder
- a builder representing the partial functionUnitMatch
that can be reusedpublic void match(I i) throws scala.MatchError
UnitMatcher<X> matcher = UnitMatcher.create(...);
matcher.match(obj);
i
- the argument to apply the match toscala.MatchError
- if there is no match