+act #17719 introduce Tuple3-22 classes for java api
This commit is contained in:
parent
2c606383e5
commit
9e3a9983a7
4 changed files with 52 additions and 7 deletions
|
|
@ -7,6 +7,10 @@ package akka.actor;
|
|||
import akka.event.Logging;
|
||||
import akka.event.Logging.LoggerInitialized;
|
||||
import akka.japi.Creator;
|
||||
import akka.japi.Pair;
|
||||
import akka.japi.tuple.Tuple22;
|
||||
import akka.japi.tuple.Tuple3;
|
||||
import akka.japi.tuple.Tuple4;
|
||||
import akka.routing.GetRoutees;
|
||||
import akka.routing.FromConfig;
|
||||
import akka.routing.NoRouter;
|
||||
|
|
@ -121,6 +125,14 @@ public class JavaAPI {
|
|||
probe.expectMsg("a-null-0-0");
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unused")
|
||||
public void mustCompileTupleCreation() {
|
||||
final Pair<Integer, String> p = Pair.create(1, "2");
|
||||
final Tuple4<Integer, String, Integer, Long> t4 = Tuple4.create(1, "2", 3, 4L);
|
||||
Tuple22.create(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22);
|
||||
}
|
||||
|
||||
public static class ActorWithConstructorParams extends UntypedActor {
|
||||
|
||||
private final String a;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* Copyright (C) 2015 Typesafe Inc. <http://www.typesafe.com>
|
||||
*/
|
||||
package akka.japi.tuple
|
||||
|
||||
[3..22#/**
|
||||
* Used to create tuples with 1 elements in Java.
|
||||
*/
|
||||
object Tuple1 {
|
||||
def create[[#T1#]]([#t1: T1#]) = new Tuple1([#t1#])
|
||||
}
|
||||
|
||||
/**
|
||||
* Java API Tuple container.
|
||||
*/
|
||||
@SerialVersionUID(##1L)
|
||||
final case class Tuple1[[#T1#]]([#t1: T1#]) {
|
||||
val toScala: ([#T1#]) = ([#t1#])
|
||||
}#
|
||||
|
||||
]
|
||||
|
|
@ -4,14 +4,15 @@
|
|||
|
||||
package akka.japi
|
||||
|
||||
import language.implicitConversions
|
||||
import java.util.Collections.{ emptyList, singletonList }
|
||||
|
||||
import akka.util.Collections.EmptyImmutableSeq
|
||||
|
||||
import scala.collection.immutable
|
||||
import scala.language.implicitConversions
|
||||
import scala.reflect.ClassTag
|
||||
import scala.util.control.NoStackTrace
|
||||
import scala.runtime.AbstractPartialFunction
|
||||
import akka.util.Collections.EmptyImmutableSeq
|
||||
import java.util.Collections.{ emptyList, singletonList }
|
||||
import scala.util.control.NoStackTrace
|
||||
|
||||
/**
|
||||
* A Function interface. Used to create first-class-functions is Java.
|
||||
|
|
@ -53,10 +54,18 @@ trait Predicate[T] {
|
|||
}
|
||||
|
||||
/**
|
||||
* Java API: Represents a tuple of two elements.
|
||||
* Java API
|
||||
* Represents a pair (tuple) of two elements.
|
||||
*
|
||||
* Additional tuple types for 3 to 22 values are defined in the `akka.japi.tuple` package, e.g. [[akka.japi.tuple.Tuple3]].
|
||||
*/
|
||||
@SerialVersionUID(1L)
|
||||
case class Pair[A, B](first: A, second: B)
|
||||
case class Pair[A, B](first: A, second: B) {
|
||||
def toScala: (A, B) = (first, second)
|
||||
}
|
||||
object Pair {
|
||||
def create[A, B](first: A, second: B): Pair[A, B] = new Pair(first, second)
|
||||
}
|
||||
|
||||
/**
|
||||
* A constructor/factory, takes no parameters but creates a new value of type T every call.
|
||||
|
|
|
|||
|
|
@ -534,7 +534,10 @@ object MiMa extends AutoPlugin {
|
|||
FilterAnyProblem("akka.remote.RemoteWatcher$UnwatchRemote"),
|
||||
FilterAnyProblem("akka.remote.RemoteWatcher$Rewatch"),
|
||||
FilterAnyProblem("akka.remote.RemoteWatcher$RewatchRemote"),
|
||||
FilterAnyProblem("akka.remote.RemoteWatcher$Stats")
|
||||
FilterAnyProblem("akka.remote.RemoteWatcher$Stats"),
|
||||
|
||||
// toString is available on any object, mima is confused due to a generated toString appearing #17722
|
||||
ProblemFilters.exclude[MissingMethodProblem]("akka.japi.Pair.toString")
|
||||
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue