OptionConverters

scala.jdk.javaapi.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.

Attributes

Source
OptionConverters.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Value members

Concrete methods

def toJava[A](o: Option[A]): Optional[A]

Converts a Scala Option to a Java Optional.

Converts a Scala Option to a Java Optional.

Type parameters

A

the element type of the Option and the resulting Optional

Value parameters

o

the Scala Option to convert

Attributes

Returns

a Java Optional containing the value, or empty if o is None

Source
OptionConverters.scala

Converts a Scala Option[java.lang.Double] to a Java OptionalDouble.

Converts a Scala Option[java.lang.Double] to a Java OptionalDouble.

Note: this method uses the boxed type java.lang.X instead of the primitive type scala.X to improve compatibility when using it in Java code (the Scala compiler emits C[Int] as C[Object] in bytecode due to scala/bug#4214). In Scala code, add import scala.jdk.OptionConverters._ and use the extension methods instead.

Value parameters

o

the Scala Option to convert

Attributes

Returns

a Java OptionalDouble containing the value, or empty if o is None

Source
OptionConverters.scala

Converts a Scala Option[java.lang.Integer] to a Java OptionalInt.

Converts a Scala Option[java.lang.Integer] to a Java OptionalInt.

Note: this method uses the boxed type java.lang.X instead of the primitive type scala.X to improve compatibility when using it in Java code (the Scala compiler emits C[Int] as C[Object] in bytecode due to scala/bug#4214). In Scala code, add import scala.jdk.OptionConverters._ and use the extension methods instead.

Value parameters

o

the Scala Option to convert

Attributes

Returns

a Java OptionalInt containing the value, or empty if o is None

Source
OptionConverters.scala

Converts a Scala Option[java.lang.Long] to a Java OptionalLong.

Converts a Scala Option[java.lang.Long] to a Java OptionalLong.

Note: this method uses the boxed type java.lang.X instead of the primitive type scala.X to improve compatibility when using it in Java code (the Scala compiler emits C[Int] as C[Object] in bytecode due to scala/bug#4214). In Scala code, add import scala.jdk.OptionConverters._ and use the extension methods instead.

Value parameters

o

the Scala Option to convert

Attributes

Returns

a Java OptionalLong containing the value, or empty if o is None

Source
OptionConverters.scala
def toScala[A](o: Optional[A]): Option[A]

Converts a Java Optional to a Scala Option.

Converts a Java Optional to a Scala Option.

Type parameters

A

the element type of the Optional

Value parameters

o

the Java Optional to convert

Attributes

Returns

a Scala Option containing the value, or None if the Optional is empty

Source
OptionConverters.scala

Converts a Java OptionalDouble to a Scala Option[java.lang.Double].

Converts a Java OptionalDouble to a Scala Option[java.lang.Double].

Note: this method uses the boxed type java.lang.X instead of the primitive type scala.X to improve compatibility when using it in Java code (the Scala compiler emits C[Int] as C[Object] in bytecode due to scala/bug#4214). In Scala code, add import scala.jdk.OptionConverters._ and use the extension methods instead.

Value parameters

o

the Java OptionalDouble to convert

Attributes

Returns

a Scala Option containing the value as a boxed java.lang.Double, or None if empty

Source
OptionConverters.scala

Converts a Java OptionalInt to a Scala Option[java.lang.Integer].

Converts a Java OptionalInt to a Scala Option[java.lang.Integer].

Note: this method uses the boxed type java.lang.X instead of the primitive type scala.X to improve compatibility when using it in Java code (the Scala compiler emits C[Int] as C[Object] in bytecode due to scala/bug#4214). In Scala code, add import scala.jdk.OptionConverters._ and use the extension methods instead.

Value parameters

o

the Java OptionalInt to convert

Attributes

Returns

a Scala Option containing the value as a boxed java.lang.Integer, or None if empty

Source
OptionConverters.scala

Converts a Java OptionalLong to a Scala Option[java.lang.Long].

Converts a Java OptionalLong to a Scala Option[java.lang.Long].

Note: this method uses the boxed type java.lang.X instead of the primitive type scala.X to improve compatibility when using it in Java code (the Scala compiler emits C[Int] as C[Object] in bytecode due to scala/bug#4214). In Scala code, add import scala.jdk.OptionConverters._ and use the extension methods instead.

Value parameters

o

the Java OptionalLong to convert

Attributes

Returns

a Scala Option containing the value as a boxed java.lang.Long, or None if empty

Source
OptionConverters.scala