akka.japi.pf
Class UnitMatch<I>

java.lang.Object
  extended by akka.japi.pf.UnitMatch<I>
Type Parameters:
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

Version of PartialFunction that can be built during runtime from Java. This is a specialized version of UnitMatch to map java void methods to BoxedUnit.


Field Summary
protected  scala.PartialFunction<I,R> statements
           
 
Method Summary
 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<P> type, 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>
match(java.lang.Class<P> type, FI.UnitApply<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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

statements

protected final scala.PartialFunction<I,R> statements
Method Detail

match

public static final <F,P> UnitPFBuilder<F> match(java.lang.Class<P> type,
                                                 FI.UnitApply<P> apply)
Convenience function to create a UnitPFBuilder with the first case statement added.

Parameters:
type - a type to match the argument against
apply - 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)

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 a UnitPFBuilder with the first case statement added.

Parameters:
type - a type to match the argument against
predicate - a predicate that will be evaluated on the argument if the type matches
apply - 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)

matchEquals

public static <F,P> UnitPFBuilder<F> matchEquals(P object,
                                                 FI.UnitApply<P> apply)
Convenience function to create a UnitPFBuilder with the first case statement added.

Parameters:
object - the object to compare equals with
apply - 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 a UnitPFBuilder with the first case statement added.

Parameters:
object - the object to compare equals with
predicate - a predicate that will be evaluated on the argument the object compares equal
apply - 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 a UnitPFBuilder 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 a UnitMatch 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

asPF

public scala.PartialFunction<I,R> asPF()
Turn this Match into a PartialFunction.

Returns:
a partial function representation ot his Match