On this page
Object 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)
Supertypes | |
---|---|
Self type |
Inherited implicits
Source@inline
Inherited from | Priority2FunctionExtensions |
---|
Source@inline
implicit def enrichAsJavaBiFunction[T, U, R](sf: (T, U) => R): RichFunction2AsBiFunction[T, U, R]
Inherited from | Priority3FunctionExtensions |
---|
Source@inline
Inherited from | Priority2FunctionExtensions |
---|
Source@inline
implicit def enrichAsJavaBinaryOperator[T, A1, A2](sf: (T, A1) => A2)(implicit evA1: A1 =:= T, evA2: A2 =:= T): RichFunction2AsBinaryOperator[T]
Inherited from | Priority1FunctionExtensions |
---|
Source@inline
Inherited from | Priority0FunctionExtensions |
---|
Source@inline
Inherited from | Priority1FunctionExtensions |
---|
Source@inline
implicit def enrichAsJavaDoubleBinaryOperator[A0, A1](sf: (A0, A1) => Double)(implicit evA0: A0 =:= Double, evA1: A1 =:= Double): RichFunction2AsDoubleBinaryOperator
Inherited from | Priority0FunctionExtensions |
---|
Source@inline
implicit def enrichAsJavaDoubleConsumer[A0](sf: A0 => Unit)(implicit evA0: A0 =:= Double): RichFunction1AsDoubleConsumer
Inherited from | Priority0FunctionExtensions |
---|
Source@inline
implicit def enrichAsJavaDoubleFunction[A0, R](sf: A0 => R)(implicit evA0: A0 =:= Double): RichFunction1AsDoubleFunction[R]
Inherited from | Priority1FunctionExtensions |
---|
Source@inline
implicit def enrichAsJavaDoublePredicate[A0](sf: A0 => Boolean)(implicit evA0: A0 =:= Double): RichFunction1AsDoublePredicate
Inherited from | Priority0FunctionExtensions |
---|
Source@inline
Inherited from | Priority0FunctionExtensions |
---|
Source@inline
implicit def enrichAsJavaDoubleToIntFunction[A0](sf: A0 => Int)(implicit evA0: A0 =:= Double): RichFunction1AsDoubleToIntFunction
Inherited from | Priority0FunctionExtensions |
---|
Source@inline
implicit def enrichAsJavaDoubleToLongFunction[A0](sf: A0 => Long)(implicit evA0: A0 =:= Double): RichFunction1AsDoubleToLongFunction
Inherited from | Priority0FunctionExtensions |
---|
Source@inline
implicit def enrichAsJavaDoubleUnaryOperator[A0](sf: A0 => Double)(implicit evA0: A0 =:= Double): RichFunction1AsDoubleUnaryOperator
Inherited from | Priority0FunctionExtensions |
---|
Source@inline
implicit def enrichAsJavaFunction[T, R](sf: T => R): RichFunction1AsFunction[T, R]
Inherited from | Priority2FunctionExtensions |
---|
Source@inline
implicit def enrichAsJavaIntBinaryOperator[A0, A1](sf: (A0, A1) => Int)(implicit evA0: A0 =:= Int, evA1: A1 =:= Int): RichFunction2AsIntBinaryOperator
Inherited from | Priority0FunctionExtensions |
---|
Source@inline
implicit def enrichAsJavaIntConsumer[A0](sf: A0 => Unit)(implicit evA0: A0 =:= Int): RichFunction1AsIntConsumer
Inherited from | Priority0FunctionExtensions |
---|
Source@inline
implicit def enrichAsJavaIntFunction[A0, R](sf: A0 => R)(implicit evA0: A0 =:= Int): RichFunction1AsIntFunction[R]
Inherited from | Priority1FunctionExtensions |
---|
Source@inline
implicit def enrichAsJavaIntPredicate[A0](sf: A0 => Boolean)(implicit evA0: A0 =:= Int): RichFunction1AsIntPredicate
Inherited from | Priority0FunctionExtensions |
---|
Source@inline
Inherited from | Priority0FunctionExtensions |
---|
Source@inline
implicit def enrichAsJavaIntToDoubleFunction[A0](sf: A0 => Double)(implicit evA0: A0 =:= Int): RichFunction1AsIntToDoubleFunction
Inherited from | Priority0FunctionExtensions |
---|
Source@inline
implicit def enrichAsJavaIntToLongFunction[A0](sf: A0 => Long)(implicit evA0: A0 =:= Int): RichFunction1AsIntToLongFunction
Inherited from | Priority0FunctionExtensions |
---|
Source@inline
implicit def enrichAsJavaIntUnaryOperator[A0](sf: A0 => Int)(implicit evA0: A0 =:= Int): RichFunction1AsIntUnaryOperator
Inherited from | Priority0FunctionExtensions |
---|
Source@inline
implicit def enrichAsJavaLongBinaryOperator[A0, A1](sf: (A0, A1) => Long)(implicit evA0: A0 =:= Long, evA1: A1 =:= Long): RichFunction2AsLongBinaryOperator
Inherited from | Priority0FunctionExtensions |
---|
Source@inline
implicit def enrichAsJavaLongConsumer[A0](sf: A0 => Unit)(implicit evA0: A0 =:= Long): RichFunction1AsLongConsumer
Inherited from | Priority0FunctionExtensions |
---|
Source@inline
implicit def enrichAsJavaLongFunction[A0, R](sf: A0 => R)(implicit evA0: A0 =:= Long): RichFunction1AsLongFunction[R]
Inherited from | Priority1FunctionExtensions |
---|
Source@inline
implicit def enrichAsJavaLongPredicate[A0](sf: A0 => Boolean)(implicit evA0: A0 =:= Long): RichFunction1AsLongPredicate
Inherited from | Priority0FunctionExtensions |
---|
Source@inline
Inherited from | Priority0FunctionExtensions |
---|
Source@inline
implicit def enrichAsJavaLongToDoubleFunction[A0](sf: A0 => Double)(implicit evA0: A0 =:= Long): RichFunction1AsLongToDoubleFunction
Inherited from | Priority0FunctionExtensions |
---|
Source@inline
implicit def enrichAsJavaLongToIntFunction[A0](sf: A0 => Int)(implicit evA0: A0 =:= Long): RichFunction1AsLongToIntFunction
Inherited from | Priority0FunctionExtensions |
---|
Source@inline
implicit def enrichAsJavaLongUnaryOperator[A0](sf: A0 => Long)(implicit evA0: A0 =:= Long): RichFunction1AsLongUnaryOperator
Inherited from | Priority0FunctionExtensions |
---|
Source@inline
implicit def enrichAsJavaObjDoubleConsumer[T, A1](sf: (T, A1) => Unit)(implicit evA1: A1 =:= Double): RichFunction2AsObjDoubleConsumer[T]
Inherited from | Priority1FunctionExtensions |
---|
Source@inline
implicit def enrichAsJavaObjIntConsumer[T, A1](sf: (T, A1) => Unit)(implicit evA1: A1 =:= Int): RichFunction2AsObjIntConsumer[T]
Inherited from | Priority1FunctionExtensions |
---|
Source@inline
implicit def enrichAsJavaObjLongConsumer[T, A1](sf: (T, A1) => Unit)(implicit evA1: A1 =:= Long): RichFunction2AsObjLongConsumer[T]
Inherited from | Priority1FunctionExtensions |
---|
Source@inline
Inherited from | Priority1FunctionExtensions |
---|
Source@inline
implicit def enrichAsJavaSupplier[T](sf: () => T): RichFunction0AsSupplier[T]
Inherited from | Priority1FunctionExtensions |
---|
Source@inline
implicit def enrichAsJavaToDoubleBiFunction[T, U](sf: (T, U) => Double): RichFunction2AsToDoubleBiFunction[T, U]
Inherited from | Priority2FunctionExtensions |
---|
Source@inline
Inherited from | Priority1FunctionExtensions |
---|
Source@inline
implicit def enrichAsJavaToIntBiFunction[T, U](sf: (T, U) => Int): RichFunction2AsToIntBiFunction[T, U]
Inherited from | Priority2FunctionExtensions |
---|
Source@inline
Inherited from | Priority1FunctionExtensions |
---|
Source@inline
implicit def enrichAsJavaToLongBiFunction[T, U](sf: (T, U) => Long): RichFunction2AsToLongBiFunction[T, U]
Inherited from | Priority2FunctionExtensions |
---|
Source@inline
Inherited from | Priority1FunctionExtensions |
---|
Source@inline
implicit def enrichAsJavaUnaryOperator[T, A1](sf: T => A1)(implicit evA1: A1 =:= T): RichFunction1AsUnaryOperator[T]
Inherited from | Priority1FunctionExtensions |
---|
Source@inline
implicit def enrichAsScalaFromBiConsumer[T, U](jf: BiConsumer[T, U]): RichBiConsumerAsFunction2[T, U]
Inherited from | Priority0FunctionExtensions |
---|
Source@inline
implicit def enrichAsScalaFromBiFunction[T, U, R](jf: BiFunction[T, U, R]): RichBiFunctionAsFunction2[T, U, R]
Inherited from | Priority0FunctionExtensions |
---|
Source@inline
implicit def enrichAsScalaFromBiPredicate[T, U](jf: BiPredicate[T, U]): RichBiPredicateAsFunction2[T, U]
Inherited from | Priority0FunctionExtensions |
---|
Source@inline
implicit def enrichAsScalaFromBinaryOperator[T](jf: BinaryOperator[T]): RichBinaryOperatorAsFunction2[T]
Inherited from | Priority0FunctionExtensions |
---|
Source@inline
Inherited from | Priority0FunctionExtensions |
---|
Source@inline
Inherited from | Priority0FunctionExtensions |
---|
Source@inline
Inherited from | Priority0FunctionExtensions |
---|
Source@inline
Inherited from | Priority0FunctionExtensions |
---|
Source@inline
implicit def enrichAsScalaFromDoubleFunction[R](jf: DoubleFunction[R]): RichDoubleFunctionAsFunction1[R]
Inherited from | Priority0FunctionExtensions |
---|
Source@inline
Inherited from | Priority0FunctionExtensions |
---|
Source@inline
Inherited from | Priority0FunctionExtensions |
---|
Source@inline
Inherited from | Priority0FunctionExtensions |
---|
Source@inline
Inherited from | Priority0FunctionExtensions |
---|
Source@inline
Inherited from | Priority0FunctionExtensions |
---|
Source@inline
Inherited from | Priority0FunctionExtensions |
---|
Source@inline
implicit def enrichAsScalaFromIntBinaryOperator(jf: IntBinaryOperator): RichIntBinaryOperatorAsFunction2
Inherited from | Priority0FunctionExtensions |
---|
Source@inline
Inherited from | Priority0FunctionExtensions |
---|
Source@inline
Inherited from | Priority0FunctionExtensions |
---|
Source@inline
Inherited from | Priority0FunctionExtensions |
---|
Source@inline
Inherited from | Priority0FunctionExtensions |
---|
Source@inline
Inherited from | Priority0FunctionExtensions |
---|
Source@inline
implicit def enrichAsScalaFromIntToLongFunction(jf: IntToLongFunction): RichIntToLongFunctionAsFunction1
Inherited from | Priority0FunctionExtensions |
---|
Source@inline
implicit def enrichAsScalaFromIntUnaryOperator(jf: IntUnaryOperator): RichIntUnaryOperatorAsFunction1
Inherited from | Priority0FunctionExtensions |
---|
Source@inline
Inherited from | Priority0FunctionExtensions |
---|
Source@inline
Inherited from | Priority0FunctionExtensions |
---|
Source@inline
Inherited from | Priority0FunctionExtensions |
---|
Source@inline
Inherited from | Priority0FunctionExtensions |
---|
Source@inline
Inherited from | Priority0FunctionExtensions |
---|
Source@inline
Inherited from | Priority0FunctionExtensions |
---|
Source@inline
implicit def enrichAsScalaFromLongToIntFunction(jf: LongToIntFunction): RichLongToIntFunctionAsFunction1
Inherited from | Priority0FunctionExtensions |
---|
Source@inline
implicit def enrichAsScalaFromLongUnaryOperator(jf: LongUnaryOperator): RichLongUnaryOperatorAsFunction1
Inherited from | Priority0FunctionExtensions |
---|
Source@inline
implicit def enrichAsScalaFromObjDoubleConsumer[T](jf: ObjDoubleConsumer[T]): RichObjDoubleConsumerAsFunction2[T]
Inherited from | Priority0FunctionExtensions |
---|
Source@inline
implicit def enrichAsScalaFromObjIntConsumer[T](jf: ObjIntConsumer[T]): RichObjIntConsumerAsFunction2[T]
Inherited from | Priority0FunctionExtensions |
---|
Source@inline
implicit def enrichAsScalaFromObjLongConsumer[T](jf: ObjLongConsumer[T]): RichObjLongConsumerAsFunction2[T]
Inherited from | Priority0FunctionExtensions |
---|
Source@inline
Inherited from | Priority0FunctionExtensions |
---|
Source@inline
Inherited from | Priority0FunctionExtensions |
---|
Source@inline
implicit def enrichAsScalaFromToDoubleBiFunction[T, U](jf: ToDoubleBiFunction[T, U]): RichToDoubleBiFunctionAsFunction2[T, U]
Inherited from | Priority0FunctionExtensions |
---|
Source@inline
implicit def enrichAsScalaFromToDoubleFunction[T](jf: ToDoubleFunction[T]): RichToDoubleFunctionAsFunction1[T]
Inherited from | Priority0FunctionExtensions |
---|
Source@inline
implicit def enrichAsScalaFromToIntBiFunction[T, U](jf: ToIntBiFunction[T, U]): RichToIntBiFunctionAsFunction2[T, U]
Inherited from | Priority0FunctionExtensions |
---|
Source@inline
implicit def enrichAsScalaFromToIntFunction[T](jf: ToIntFunction[T]): RichToIntFunctionAsFunction1[T]
Inherited from | Priority0FunctionExtensions |
---|
Source@inline
implicit def enrichAsScalaFromToLongBiFunction[T, U](jf: ToLongBiFunction[T, U]): RichToLongBiFunctionAsFunction2[T, U]
Inherited from | Priority0FunctionExtensions |
---|
Source@inline
implicit def enrichAsScalaFromToLongFunction[T](jf: ToLongFunction[T]): RichToLongFunctionAsFunction1[T]
Inherited from | Priority0FunctionExtensions |
---|
Source@inline
implicit def enrichAsScalaFromUnaryOperator[T](jf: UnaryOperator[T]): RichUnaryOperatorAsFunction1[T]
Inherited from | Priority0FunctionExtensions |
---|
© 2002-2022 EPFL, with contributions from Lightbend.
Licensed under the Apache License, Version 2.0.
https://scala-lang.org/api/3.1.1/scala/jdk/FunctionConverters$.html