Package akka.japi.pf
Class UnitMatch<I>
- java.lang.Object
-
- akka.japi.pf.UnitMatch<I>
-
- Type Parameters:
I
- the input type, that this PartialFunction will be applied to
public class UnitMatch<I> extends java.lang.Object
Version ofPartialFunction
that can be built during runtime from Java. This is a specialized version ofUnitMatch
to map java void methods toBoxedUnit
.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description scala.PartialFunction<I,R>
asPF()
Turn thisMatch
into aPartialFunction
.static <F> UnitMatch<F>
create(UnitPFBuilder<F> builder)
Create aUnitMatch
from the builder.void
match(I i)
Convenience function to make the Java code more readable.static <F,P>
UnitPFBuilder<F>match(java.lang.Class<P> type, FI.TypedPredicate<P> predicate, FI.UnitApply<P> apply)
Convenience function to create aUnitPFBuilder
with the first case statement added.static <F,P>
UnitPFBuilder<F>match(java.lang.Class<P> type, FI.UnitApply<P> apply)
Convenience function to create aUnitPFBuilder
with the first case statement added.static <F> UnitPFBuilder<F>
matchAny(FI.UnitApply<java.lang.Object> apply)
Convenience function to create aUnitPFBuilder
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 aUnitPFBuilder
with the first case statement added.static <F,P>
UnitPFBuilder<F>matchEquals(P object, FI.UnitApply<P> apply)
Convenience function to create aUnitPFBuilder
with the first case statement added.static <F,P>
UnitPFBuilder<F>matchUnchecked(java.lang.Class<?> type, FI.TypedPredicate<?> predicate, FI.UnitApply<?> apply)
Convenience function to create aUnitPFBuilder
with the first case statement added.static UnitPFBuilder<java.lang.Object>
matchUnchecked(java.lang.Class<?> type, FI.UnitApply<?> apply)
Convenience function to create aUnitPFBuilder
with the first case statement added.
-
-
-
Method Detail
-
match
public static <F,P> UnitPFBuilder<F> match(java.lang.Class<P> type, FI.UnitApply<P> apply)
Convenience function to create aUnitPFBuilder
with the first case statement added.- 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
- See Also:
UnitPFBuilder.match(Class, FI.UnitApply)
-
matchUnchecked
public static UnitPFBuilder<java.lang.Object> matchUnchecked(java.lang.Class<?> type, FI.UnitApply<?> apply)
Convenience function to create aUnitPFBuilder
with the first case statement added. Should normally not be used.
-
match
public static <F,P> UnitPFBuilder<F> match(java.lang.Class<P> type, FI.TypedPredicate<P> predicate, FI.UnitApply<P> apply)
Convenience function to create aUnitPFBuilder
with the first case statement added.- 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 and predicate matches- Returns:
- a builder with the case statement added
- See Also:
UnitPFBuilder.match(Class, FI.TypedPredicate, FI.UnitApply)
-
matchUnchecked
public static <F,P> UnitPFBuilder<F> matchUnchecked(java.lang.Class<?> type, FI.TypedPredicate<?> predicate, FI.UnitApply<?> apply)
Convenience function to create aUnitPFBuilder
with the first case statement added. Should normally not be used.
-
matchEquals
public static <F,P> UnitPFBuilder<F> matchEquals(P object, FI.UnitApply<P> apply)
Convenience function to create aUnitPFBuilder
with the first case statement added.- 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
- See Also:
UnitPFBuilder.matchEquals(Object, FI.UnitApply)
-
matchEquals
public static <F,P> UnitPFBuilder<F> matchEquals(P object, FI.TypedPredicate<P> predicate, FI.UnitApply<P> apply)
Convenience function to create aUnitPFBuilder
with the first case statement added.- Parameters:
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 equal- Returns:
- a builder with the case statement added
- See Also:
UnitPFBuilder.matchEquals(Object, FI.UnitApply)
-
matchAny
public static <F> UnitPFBuilder<F> matchAny(FI.UnitApply<java.lang.Object> apply)
Convenience function to create aUnitPFBuilder
with the first case statement added.- Parameters:
apply
- an action to apply to the argument- Returns:
- a builder with the case statement added
- See Also:
UnitPFBuilder.matchAny(FI.UnitApply)
-
create
public static <F> UnitMatch<F> create(UnitPFBuilder<F> builder)
Create aUnitMatch
from the builder.- Parameters:
builder
- a builder representing the partial function- Returns:
- a
UnitMatch
that can be reused
-
match
public void match(I i) throws scala.MatchError
Convenience function to make the Java code more readable.UnitMatcher<X> matcher = UnitMatcher.create(...); matcher.match(obj);
- Parameters:
i
- the argument to apply the match to- Throws:
scala.MatchError
- if there is no match
-
-