This object provides extension methods that convert between ScalaOption and JavaOptional types.
When writing Java code, use the explicit conversion methods defined injavaapi.OptionConverters instead.
ScalaOption is extended with atoJava method that creates a correspondingOptional, and atoJavaPrimitive method that creates a specialized variant (e.g.,OptionalInt) if applicable.
JavaOptional is extended with atoScala method and atoJavaPrimitive method.
Finally, specializedOptional types are extended withtoScala andtoJavaGeneric methods.
Example usage:
import scala.jdk.OptionConverters._val a = Option("example").toJava // Creates java.util.Optional[String] containing "example"val b = (None: Option[String]).toJava // Creates an empty java.util.Optional[String]val c = a.toScala // Back to Option("example")val d = b.toScala // Back to None typed as Option[String]val e = Option(2.7).toJava // java.util.Optional[Double] containing boxed 2.7val f = Option(2.7).toJavaPrimitive // java.util.OptionalDouble containing 2.7 (not boxed)val g = f.toScala // Back to Option(2.7)val h = f.toJavaGeneric // Same as eval i = e.toJavaPrimitive // Same as fProvides conversions from ScalaOption to JavaOptional types
Provides conversions from ScalaOption to JavaOptional types
Provides conversions from JavaOptional to ScalaOption and specializedOptional types
Provides conversions from JavaOptional to ScalaOption and specializedOptional types
Provides conversions fromOptionalDouble to ScalaOption and the genericOptional
Provides conversions fromOptionalDouble to ScalaOption and the genericOptional
Provides conversions fromOptionalInt to ScalaOption and the genericOptional
Provides conversions fromOptionalInt to ScalaOption and the genericOptional
Provides conversions fromOptionalLong to ScalaOption and the genericOptional
Provides conversions fromOptionalLong to ScalaOption and the genericOptional
Provides conversions from ScalaOption to JavaOptional types
Provides conversions from JavaOptional to ScalaOption and specializedOptional types
Provides conversions from JavaOptional to ScalaOption and specializedOptional types
Provides conversions fromOptionalDouble to ScalaOption and the genericOptional
Provides conversions fromOptionalDouble to ScalaOption and the genericOptional
Provides conversions fromOptionalInt to ScalaOption and the genericOptional
Provides conversions fromOptionalInt to ScalaOption and the genericOptional
Provides conversions fromOptionalLong to ScalaOption and the genericOptional
Provides conversions fromOptionalLong to ScalaOption and the genericOptional