FunctionConverters
scala.jdk.FunctionConverters
object FunctionConverters extends Priority0FunctionExtensions
This object provides extension methods that convert between Scala and Java function types.
When writing Java code, use the explicit conversion methods defined in javaapi.FunctionConverters instead.
Using the .asJava extension method on a Scala function produces the most specific possible Java function type:
scala> import scala.jdk.FunctionConverters._
scala> val f = (x: Int) => x + 1
scala> val jf1 = f.asJava
jf1: java.util.function.IntUnaryOperator = ...
More generic Java function types can be created using the corresponding asJavaXYZ extension method:
scala> val jf2 = f.asJavaFunction
jf2: java.util.function.Function[Int,Int] = ...
scala> val jf3 = f.asJavaUnaryOperator
jf3: java.util.function.UnaryOperator[Int] = ...
Converting a Java function to Scala is done using the asScala extension method:
scala> List(1,2,3).map(jf2.asScala)
res1: List[Int] = List(2, 3, 4)
Attributes
- Graph
-
- Supertypes
- Self type
-
FunctionConverters.type
Members list
Implicits
Inherited implicits
Attributes
- Inherited from:
- Priority2FunctionExtensions
Attributes
- Inherited from:
- Priority3FunctionExtensions
Attributes
- Inherited from:
- Priority2FunctionExtensions
Attributes
- Inherited from:
- Priority1FunctionExtensions
Attributes
- Inherited from:
- Priority0FunctionExtensions
Attributes
- Inherited from:
- Priority1FunctionExtensions
Attributes
- Inherited from:
- Priority0FunctionExtensions
implicit def enrichAsJavaDoubleConsumer[A0](sf: A0 => Unit)(implicit evA0: A0 =:= Double): RichFunction1AsDoubleConsumer
Attributes
- Inherited from:
- Priority0FunctionExtensions
Attributes
- Inherited from:
- Priority1FunctionExtensions
implicit def enrichAsJavaDoublePredicate[A0](sf: A0 => Boolean)(implicit evA0: A0 =:= Double): RichFunction1AsDoublePredicate
Attributes
- Inherited from:
- Priority0FunctionExtensions
Attributes
- Inherited from:
- Priority0FunctionExtensions
implicit def enrichAsJavaDoubleToIntFunction[A0](sf: A0 => Int)(implicit evA0: A0 =:= Double): RichFunction1AsDoubleToIntFunction
Attributes
- Inherited from:
- Priority0FunctionExtensions
implicit def enrichAsJavaDoubleToLongFunction[A0](sf: A0 => Long)(implicit evA0: A0 =:= Double): RichFunction1AsDoubleToLongFunction
Attributes
- Inherited from:
- Priority0FunctionExtensions
implicit def enrichAsJavaDoubleUnaryOperator[A0](sf: A0 => Double)(implicit evA0: A0 =:= Double): RichFunction1AsDoubleUnaryOperator
Attributes
- Inherited from:
- Priority0FunctionExtensions
Attributes
- Inherited from:
- Priority2FunctionExtensions
Attributes
- Inherited from:
- Priority0FunctionExtensions
implicit def enrichAsJavaIntConsumer[A0](sf: A0 => Unit)(implicit evA0: A0 =:= Int): RichFunction1AsIntConsumer
Attributes
- Inherited from:
- Priority0FunctionExtensions
Attributes
- Inherited from:
- Priority1FunctionExtensions
implicit def enrichAsJavaIntPredicate[A0](sf: A0 => Boolean)(implicit evA0: A0 =:= Int): RichFunction1AsIntPredicate
Attributes
- Inherited from:
- Priority0FunctionExtensions
Attributes
- Inherited from:
- Priority0FunctionExtensions
implicit def enrichAsJavaIntToDoubleFunction[A0](sf: A0 => Double)(implicit evA0: A0 =:= Int): RichFunction1AsIntToDoubleFunction
Attributes
- Inherited from:
- Priority0FunctionExtensions
implicit def enrichAsJavaIntToLongFunction[A0](sf: A0 => Long)(implicit evA0: A0 =:= Int): RichFunction1AsIntToLongFunction
Attributes
- Inherited from:
- Priority0FunctionExtensions
implicit def enrichAsJavaIntUnaryOperator[A0](sf: A0 => Int)(implicit evA0: A0 =:= Int): RichFunction1AsIntUnaryOperator
Attributes
- Inherited from:
- Priority0FunctionExtensions
Attributes
- Inherited from:
- Priority0FunctionExtensions
implicit def enrichAsJavaLongConsumer[A0](sf: A0 => Unit)(implicit evA0: A0 =:= Long): RichFunction1AsLongConsumer
Attributes
- Inherited from:
- Priority0FunctionExtensions
Attributes
- Inherited from:
- Priority1FunctionExtensions
implicit def enrichAsJavaLongPredicate[A0](sf: A0 => Boolean)(implicit evA0: A0 =:= Long): RichFunction1AsLongPredicate
Attributes
- Inherited from:
- Priority0FunctionExtensions
Attributes
- Inherited from:
- Priority0FunctionExtensions
implicit def enrichAsJavaLongToDoubleFunction[A0](sf: A0 => Double)(implicit evA0: A0 =:= Long): RichFunction1AsLongToDoubleFunction
Attributes
- Inherited from:
- Priority0FunctionExtensions
implicit def enrichAsJavaLongToIntFunction[A0](sf: A0 => Int)(implicit evA0: A0 =:= Long): RichFunction1AsLongToIntFunction
Attributes
- Inherited from:
- Priority0FunctionExtensions
implicit def enrichAsJavaLongUnaryOperator[A0](sf: A0 => Long)(implicit evA0: A0 =:= Long): RichFunction1AsLongUnaryOperator
Attributes
- Inherited from:
- Priority0FunctionExtensions
Attributes
- Inherited from:
- Priority1FunctionExtensions
Attributes
- Inherited from:
- Priority1FunctionExtensions
Attributes
- Inherited from:
- Priority1FunctionExtensions
Attributes
- Inherited from:
- Priority1FunctionExtensions
Attributes
- Inherited from:
- Priority1FunctionExtensions
implicit def enrichAsJavaToDoubleBiFunction[T, U](sf: (T, U) => Double): RichFunction2AsToDoubleBiFunction[T, U]
Attributes
- Inherited from:
- Priority2FunctionExtensions
Attributes
- Inherited from:
- Priority1FunctionExtensions
implicit def enrichAsJavaToIntBiFunction[T, U](sf: (T, U) => Int): RichFunction2AsToIntBiFunction[T, U]
Attributes
- Inherited from:
- Priority2FunctionExtensions
Attributes
- Inherited from:
- Priority1FunctionExtensions
implicit def enrichAsJavaToLongBiFunction[T, U](sf: (T, U) => Long): RichFunction2AsToLongBiFunction[T, U]
Attributes
- Inherited from:
- Priority2FunctionExtensions
Attributes
- Inherited from:
- Priority1FunctionExtensions
Attributes
- Inherited from:
- Priority1FunctionExtensions
implicit def enrichAsScalaFromBiConsumer[T, U](jf: BiConsumer[T, U]): RichBiConsumerAsFunction2[T, U]
Attributes
- Inherited from:
- Priority0FunctionExtensions
implicit def enrichAsScalaFromBiFunction[T, U, R](jf: BiFunction[T, U, R]): RichBiFunctionAsFunction2[T, U, R]
Attributes
- Inherited from:
- Priority0FunctionExtensions
implicit def enrichAsScalaFromBiPredicate[T, U](jf: BiPredicate[T, U]): RichBiPredicateAsFunction2[T, U]
Attributes
- Inherited from:
- Priority0FunctionExtensions
implicit def enrichAsScalaFromBinaryOperator[T](jf: BinaryOperator[T]): RichBinaryOperatorAsFunction2[T]
Attributes
- Inherited from:
- Priority0FunctionExtensions
Attributes
- Inherited from:
- Priority0FunctionExtensions
Attributes
- Inherited from:
- Priority0FunctionExtensions
Attributes
- Inherited from:
- Priority0FunctionExtensions
Attributes
- Inherited from:
- Priority0FunctionExtensions
implicit def enrichAsScalaFromDoubleFunction[R](jf: DoubleFunction[R]): RichDoubleFunctionAsFunction1[R]
Attributes
- Inherited from:
- Priority0FunctionExtensions
Attributes
- Inherited from:
- Priority0FunctionExtensions
Attributes
- Inherited from:
- Priority0FunctionExtensions
Attributes
- Inherited from:
- Priority0FunctionExtensions
Attributes
- Inherited from:
- Priority0FunctionExtensions
Attributes
- Inherited from:
- Priority0FunctionExtensions
Attributes
- Inherited from:
- Priority0FunctionExtensions
Attributes
- Inherited from:
- Priority0FunctionExtensions
Attributes
- Inherited from:
- Priority0FunctionExtensions
Attributes
- Inherited from:
- Priority0FunctionExtensions
Attributes
- Inherited from:
- Priority0FunctionExtensions
Attributes
- Inherited from:
- Priority0FunctionExtensions
Attributes
- Inherited from:
- Priority0FunctionExtensions
Attributes
- Inherited from:
- Priority0FunctionExtensions
Attributes
- Inherited from:
- Priority0FunctionExtensions
Attributes
- Inherited from:
- Priority0FunctionExtensions
Attributes
- Inherited from:
- Priority0FunctionExtensions
Attributes
- Inherited from:
- Priority0FunctionExtensions
Attributes
- Inherited from:
- Priority0FunctionExtensions
Attributes
- Inherited from:
- Priority0FunctionExtensions
Attributes
- Inherited from:
- Priority0FunctionExtensions
Attributes
- Inherited from:
- Priority0FunctionExtensions
Attributes
- Inherited from:
- Priority0FunctionExtensions
implicit def enrichAsScalaFromObjDoubleConsumer[T](jf: ObjDoubleConsumer[T]): RichObjDoubleConsumerAsFunction2[T]
Attributes
- Inherited from:
- Priority0FunctionExtensions
implicit def enrichAsScalaFromObjIntConsumer[T](jf: ObjIntConsumer[T]): RichObjIntConsumerAsFunction2[T]
Attributes
- Inherited from:
- Priority0FunctionExtensions
implicit def enrichAsScalaFromObjLongConsumer[T](jf: ObjLongConsumer[T]): RichObjLongConsumerAsFunction2[T]
Attributes
- Inherited from:
- Priority0FunctionExtensions
Attributes
- Inherited from:
- Priority0FunctionExtensions
Attributes
- Inherited from:
- Priority0FunctionExtensions
implicit def enrichAsScalaFromToDoubleBiFunction[T, U](jf: ToDoubleBiFunction[T, U]): RichToDoubleBiFunctionAsFunction2[T, U]
Attributes
- Inherited from:
- Priority0FunctionExtensions
implicit def enrichAsScalaFromToDoubleFunction[T](jf: ToDoubleFunction[T]): RichToDoubleFunctionAsFunction1[T]
Attributes
- Inherited from:
- Priority0FunctionExtensions
implicit def enrichAsScalaFromToIntBiFunction[T, U](jf: ToIntBiFunction[T, U]): RichToIntBiFunctionAsFunction2[T, U]
Attributes
- Inherited from:
- Priority0FunctionExtensions
implicit def enrichAsScalaFromToIntFunction[T](jf: ToIntFunction[T]): RichToIntFunctionAsFunction1[T]
Attributes
- Inherited from:
- Priority0FunctionExtensions
implicit def enrichAsScalaFromToLongBiFunction[T, U](jf: ToLongBiFunction[T, U]): RichToLongBiFunctionAsFunction2[T, U]
Attributes
- Inherited from:
- Priority0FunctionExtensions
implicit def enrichAsScalaFromToLongFunction[T](jf: ToLongFunction[T]): RichToLongFunctionAsFunction1[T]
Attributes
- Inherited from:
- Priority0FunctionExtensions
implicit def enrichAsScalaFromUnaryOperator[T](jf: UnaryOperator[T]): RichUnaryOperatorAsFunction1[T]
Attributes
- Inherited from:
- Priority0FunctionExtensions
In this article