2015-10-21 22:45:39 +02:00
|
|
|
/**
|
|
|
|
|
* Copyright (C) 2015 Typesafe Inc. <http://www.typesafe.com>
|
|
|
|
|
*/
|
|
|
|
|
package akka.stream.impl
|
|
|
|
|
|
|
|
|
|
import akka.japi.function.{ Function ⇒ JFun, Function2 ⇒ JFun2 }
|
|
|
|
|
import akka.japi.{ Pair ⇒ JPair }
|
|
|
|
|
|
2015-11-03 14:46:17 +01:00
|
|
|
private[akka] object ConstantFun {
|
2015-10-21 22:45:39 +02:00
|
|
|
private[this] val JavaIdentityFunction = new JFun[Any, Any] {
|
|
|
|
|
@throws(classOf[Exception]) override def apply(param: Any): Any = param
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
val JavaPairFunction = new JFun2[AnyRef, AnyRef, AnyRef JPair AnyRef] {
|
|
|
|
|
def apply(p1: AnyRef, p2: AnyRef): AnyRef JPair AnyRef = JPair(p1, p2)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
def javaCreatePairFunction[A, B]: JFun2[A, B, JPair[A, B]] = JavaPairFunction.asInstanceOf[JFun2[A, B, JPair[A, B]]]
|
|
|
|
|
|
|
|
|
|
def javaIdentityFunction[T]: JFun[T, T] = JavaIdentityFunction.asInstanceOf[JFun[T, T]]
|
|
|
|
|
|
2015-11-25 19:58:48 +01:00
|
|
|
def scalaIdentityFunction[T]: T ⇒ T = conforms
|
2016-01-20 18:20:12 +02:00
|
|
|
|
|
|
|
|
def returnZero[T](t: T): Long = 0L
|
|
|
|
|
|
|
|
|
|
def returnOne[T](t: T): Long = 1L
|
2015-10-21 22:45:39 +02:00
|
|
|
}
|