Package scala.jdk.javaapi
package javaapi
Value Members
object CollectionConverters extends AsJavaConverters with AsScalaConverters
object DurationConverters
This object contains methods that convert between Scala and Java duration types.
The explicit conversion methods defined here are intended to be used in Java code. For Scala code, it is recommended to use the extension methods defined in scala.jdk.DurationConverters.
object FunctionConverters
This object contains methods that convert between Scala and Java function types.
The explicit conversion methods defined here are intended to be used in Java code. For Scala code, it is recommended to use the extension methods defined in scala.jdk.FunctionConverters.
For details how the function converters work, see scala.jdk.FunctionConverters.
object FutureConverters
This object contains methods that convert between Scala Future and Java CompletionStage.
The explicit conversion methods defined here are intended to be used in Java code. For Scala code, it is recommended to use the extension methods defined in scala.jdk.FutureConverters.
Note that the bridge is implemented at the read-only side of asynchronous handles, namely Future (instead of scala.concurrent.Promise) and CompletionStage (instead of java.util.concurrent.CompletableFuture). This is intentional, as the semantics of bridging the write-handles would be prone to race conditions; if both ends (CompletableFuture
and Promise
) are completed independently at the same time, they may contain different values afterwards. For this reason, toCompletableFuture
is not supported on the created CompletionStage
s.
object OptionConverters
This object contains methods that convert between Scala Option
and Java Optional
types.
The explicit conversion methods defined here are intended to be used in Java code. For Scala code, it is recommended to use the extension methods defined in scala.jdk.OptionConverters.
object StreamConverters
This object contains methods to create Java Streams that operate on Scala collections (sequentially or in parallel). For more information on Java streams, consult the documentation (https://docs.oracle.com/javase/8/docs/api/java/util/stream/package-summary.html).
The explicit conversion methods defined here are intended to be used in Java code. For Scala code, it is recommended to use the extension methods defined in scala.jdk.StreamConverters.
Note: to convert between Scala collections and classic Java collections, use CollectionConverters.
For details how the stream converters work, see scala.jdk.StreamConverters.
© 2002-2019 EPFL, with contributions from Lightbend.
Licensed under the Apache License, Version 2.0.
https://www.scala-lang.org/api/2.13.0/scala/jdk/javaapi/index.html
This object contains methods that convert between Scala and Java collections.
The explicit conversion methods defined here are intended to be used in Java code. For Scala code, it is recommended to use the extension methods defined in scala.jdk.CollectionConverters.
Note: to create Java Streams that operate on Scala collections (sequentially or in parallel), use StreamConverters.
The conversions return adapters for the corresponding API, i.e., the collections are wrapped, not converted. Changes to the original collection are reflected in the view, and vice versa.
The following conversions are supported via
asScala
andasJava
:The following conversions are supported via
asScala
and through specially-named methods to convert to Java collections, as shown:In addition, the following one-way conversions are provided via
asJava
:The following one way conversion is provided via
asScala
:In all cases, converting from a source type to a target type and back again will return the original source object.