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

sealed abstract class SpecializerOfOptions[A, That] extends AnyRef

Type class implementing conversion from generic Option or Optional to manually specialized variants.

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

Abstract Value Members

  1. abstract def fromJava(o: Optional[A]): That

    Converts from Optional to a manually specialized variant That

  2. abstract def fromScala(o: Option[A]): That

    Converts from Option to a manually specialized variant That

Concrete Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native() @IntrinsicCandidate()
  6. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  7. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  8. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @IntrinsicCandidate()
  9. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @IntrinsicCandidate()
  10. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  11. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  12. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @IntrinsicCandidate()
  13. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @IntrinsicCandidate()
  14. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  15. def toString(): String
    Definition Classes
    AnyRef → Any
  16. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  17. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  18. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])

Deprecated Value Members

  1. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable]) @Deprecated
    Deprecated

Inherited from AnyRef

Inherited from Any

Ungrouped