Packages

  • package root
    Definition Classes
    root
  • package kinesis4cats
    Definition Classes
    root
  • package compat
    Definition Classes
    kinesis4cats
  • object OptionConverters

    This class enables bidirectional conversion between scala.Option and the set of java.util.Optional classes.

    This class enables bidirectional conversion between scala.Option and the set of java.util.Optional classes.

    The Scala Option is generic; its generic counterpart in Java is java.util.Optional. Option is enriched with an asJava method, while Optional is enriched with asScala to perform conversions.

    In addition, both Option and Optional are enriched with asPrimitive methods that will convert generically contained primitives to the manually specialized Java versions for primitives, OptionalDouble, OptionalInt, and OptionalLong. The primitive versions can be converted to the Scala generic Option with asScala and to the Java generic Optional with asGeneric.

    When calling from Java, methods are more convenient than extension methods, so toJava and toScala methods are provided that convert to and from Scala's Option. Note that toJava(toScala(x)) will result in a generic Optional even if x was one of the primitive versons.

    Example usage:

    import scala.compat.java8.OptionConverters._
    val a = Option("example").asJava      // Creates java.util.Optional[String] containing "example"
    val b = (None: Option[String]).asJava // Creates an empty java.util.Optional[String]
    val c = a.asScala                     // Back to Option("example")
    val d = b.asScala                     // Back to None typed as Option[String]
    val e = Option(2.7).asJava            // java.util.Optional[Double] containing boxed 2.7
    val f = Option(2.7).asPrimitive       // java.util.OptionalDouble containing 2.7 (not boxed)
    val g = f.asScala                     // Back to Option(2.7)
    val h = f.asGeneric                   // Same as e
    val i = e.asPrimitive                 // Same as f
    val j = toJava(Option("example"))     // Same as a
    val k = toScala(a)                    // Same as c
    Definition Classes
    compat
  • RichOptionForJava8
  • RichOptionalDouble
  • RichOptionalGeneric
  • RichOptionalInt
  • RichOptionalLong
  • SpecializerOfOptions

implicit final class RichOptionalInt extends AnyVal

Provides conversions from java.util.OptionalInt to the generic Optional and Scala Option

Source
OptionConverters.scala
Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. RichOptionalInt
  2. AnyVal
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Instance Constructors

  1. new RichOptionalInt(underlying: OptionalInt)

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    Any
  2. final def ##: Int
    Definition Classes
    Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    Any
  4. def asGeneric: Optional[Int]

    Create a generic java.util.Optional version of this OptionalInt

  5. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  6. def asScala: Option[Int]

    Create a scala.Option version of this OptionalInt

  7. def getClass(): Class[_ <: AnyVal]
    Definition Classes
    AnyVal → Any
  8. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  9. def toString(): String
    Definition Classes
    Any
  10. val underlying: OptionalInt

Inherited from AnyVal

Inherited from Any

Ungrouped