+act #3770 Added Java 8 friendly APIs for Actor and FSM
This commit is contained in:
parent
301b735516
commit
e5bcf8bfc9
28 changed files with 2204 additions and 15 deletions
36
akka-actor/src/main/java/akka/japi/pf/AbstractMatch.java
Normal file
36
akka-actor/src/main/java/akka/japi/pf/AbstractMatch.java
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
/**
|
||||
* Copyright (C) 2009-2014 Typesafe Inc. <http://www.typesafe.com>
|
||||
*/
|
||||
|
||||
package akka.japi.pf;
|
||||
|
||||
import scala.PartialFunction;
|
||||
|
||||
/**
|
||||
* Version of {@link scala.PartialFunction} that can be built during
|
||||
* runtime from Java.
|
||||
*
|
||||
* @param <I> the input type, that this PartialFunction will be applied to
|
||||
* @param <R> the return type, that the results of the application will have
|
||||
*/
|
||||
class AbstractMatch<I, R> {
|
||||
|
||||
protected final PartialFunction<I, R> statements;
|
||||
|
||||
AbstractMatch(PartialFunction<I, R> statements) {
|
||||
PartialFunction<I, R> empty = CaseStatement.empty();
|
||||
if (statements == null)
|
||||
this.statements = empty;
|
||||
else
|
||||
this.statements = statements.orElse(empty);
|
||||
}
|
||||
|
||||
/**
|
||||
* Turn this {@link Match} into a {@link scala.PartialFunction}.
|
||||
*
|
||||
* @return a partial function representation ot his {@link Match}
|
||||
*/
|
||||
public PartialFunction<I, R> asPF() {
|
||||
return statements;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue