revert changes to java api
This commit is contained in:
parent
c62e6096d3
commit
e18cc7bac6
3 changed files with 17 additions and 6 deletions
|
|
@ -62,8 +62,8 @@ class FutureSpec extends JUnitSuite {
|
|||
def shouldFutureCompose {
|
||||
val actor1 = actorOf[TestActor].start()
|
||||
val actor2 = actorOf(new Actor { def receive = { case s: String ⇒ self reply s.toUpperCase } }).start()
|
||||
val future1 = actor1 ? "Hello" flatMap { case s: String ⇒ actor2 ? s }
|
||||
val future2 = actor1 ? "Hello" flatMap { case i: Int ⇒ actor2 ? i }
|
||||
val future1 = actor1 ? "Hello" flatMap { _ match { case s: String ⇒ actor2 ? s } }
|
||||
val future2 = actor1 ? "Hello" flatMap { _ match { case i: Int ⇒ actor2 ? i } }
|
||||
assert((future1.get: Any) === "WORLD")
|
||||
intercept[MatchError] { future2.get }
|
||||
actor1.stop()
|
||||
|
|
|
|||
|
|
@ -620,6 +620,17 @@ sealed trait Future[+T] {
|
|||
} else None
|
||||
}
|
||||
|
||||
/* Java API */
|
||||
final def onComplete[A >: T](proc: Procedure[Future[A]]): this.type = onComplete(proc(_))
|
||||
|
||||
final def map[A >: T, B](f: JFunc[A, B]): Future[B] = map(f(_))
|
||||
|
||||
final def flatMap[A >: T, B](f: JFunc[A, Future[B]]): Future[B] = flatMap(f(_))
|
||||
|
||||
final def foreach[A >: T](proc: Procedure[A]): Unit = foreach(proc(_))
|
||||
|
||||
final def filter(p: JFunc[Any, Boolean]): Future[Any] = filter(p(_))
|
||||
|
||||
}
|
||||
|
||||
object Promise {
|
||||
|
|
|
|||
|
|
@ -3,28 +3,28 @@ package akka.japi
|
|||
/**
|
||||
* A Function interface. Used to create first-class-functions is Java (sort of).
|
||||
*/
|
||||
abstract class Function[-T, +R] extends scala.Function1[T, R] {
|
||||
trait Function[T, R] {
|
||||
def apply(param: T): R
|
||||
}
|
||||
|
||||
/**
|
||||
* A Function interface. Used to create 2-arg first-class-functions is Java (sort of).
|
||||
*/
|
||||
abstract class Function2[-T1, -T2, +R] extends scala.Function2[T1, T2, R] {
|
||||
trait Function2[T1, T2, R] {
|
||||
def apply(arg1: T1, arg2: T2): R
|
||||
}
|
||||
|
||||
/**
|
||||
* A Procedure is like a Function, but it doesn't produce a return value
|
||||
*/
|
||||
abstract class Procedure[-T] extends scala.Function1[T, Unit] {
|
||||
trait Procedure[T] {
|
||||
def apply(param: T): Unit
|
||||
}
|
||||
|
||||
/**
|
||||
* A Procedure is like a Function, but it doesn't produce a return value
|
||||
*/
|
||||
abstract class Procedure2[-T1, -T2] extends scala.Function2[T1, T2, Unit] {
|
||||
trait Procedure2[T1, T2] {
|
||||
def apply(param: T1, param2: T2): Unit
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue