Class/Object

com.avsystem.commons.misc

OptRef

Related Docs: object OptRef | package misc

Permalink

final class OptRef[+A >: Null] extends AnyVal with Serializable

Like Opt but has better Java interop thanks to the fact that wrapped value has type A instead of Any. For example, Scala method defined like this:

def takeMaybeString(str: OptRef[String]): Unit

will be seen by Java as:

public void takeMaybeString(String str);

and null will be used to represent absence of value.

This comes at the cost of A having to be a nullable type. Also, empty value is represented internally using null which unfortunately makes OptRef suffer from SI-7396 (hashCode fails on OptRef.Empty which means that you can't add OptRef values into hash sets or use them as hash map keys).

Author: ghik Created: 07/01/16.

Linear Supertypes
Serializable, Serializable, AnyVal, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. OptRef
  2. Serializable
  3. Serializable
  4. AnyVal
  5. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    Any
  4. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  5. def collect[B >: Null](pf: PartialFunction[A, B]): OptRef[B]

    Permalink
    Annotations
    @inline()
  6. def contains[A1 >: A](elem: A1): Boolean

    Permalink
    Annotations
    @inline()
  7. def exists(p: (A) ⇒ Boolean): Boolean

    Permalink
    Annotations
    @inline()
  8. def filter(p: (A) ⇒ Boolean): OptRef[A]

    Permalink
    Annotations
    @inline()
  9. def filterNot(p: (A) ⇒ Boolean): OptRef[A]

    Permalink
    Annotations
    @inline()
  10. def flatMap[B >: Null](f: (A) ⇒ OptRef[B]): OptRef[B]

    Permalink
    Annotations
    @inline()
  11. def fold[B >: Null](ifEmpty: ⇒ B)(f: (A) ⇒ B): B

    Permalink
    Annotations
    @inline()
  12. def forall(p: (A) ⇒ Boolean): Boolean

    Permalink
    Annotations
    @inline()
  13. def foreach[U](f: (A) ⇒ U): Unit

    Permalink
    Annotations
    @inline()
  14. def get: A

    Permalink
    Annotations
    @inline()
  15. def getClass(): Class[_ <: AnyVal]

    Permalink
    Definition Classes
    AnyVal → Any
  16. def getOrElse[B >: A](default: ⇒ B): B

    Permalink
    Annotations
    @inline()
  17. def isDefined: Boolean

    Permalink
    Annotations
    @inline()
  18. def isEmpty: Boolean

    Permalink
    Annotations
    @inline()
  19. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  20. def iterator: Iterator[A]

    Permalink
    Annotations
    @inline()
  21. def map[B >: Null](f: (A) ⇒ B): OptRef[B]

    Permalink
    Annotations
    @inline()
  22. def nonEmpty: Boolean

    Permalink
    Annotations
    @inline()
  23. def orElse[B >: A](alternative: ⇒ OptRef[B]): OptRef[B]

    Permalink
    Annotations
    @inline()
  24. def orNull[B >: A](implicit ev: <:<[Null, B]): B

    Permalink
    Annotations
    @inline()
  25. def toLeft[X](right: ⇒ X): Product with Serializable with Either[A, X]

    Permalink
    Annotations
    @inline()
  26. def toList: List[A]

    Permalink
    Annotations
    @inline()
  27. def toOpt: Opt[A]

    Permalink
    Annotations
    @inline()
  28. def toOption: Option[A]

    Permalink
    Annotations
    @inline()
  29. def toRight[X](left: ⇒ X): Product with Serializable with Either[X, A]

    Permalink
    Annotations
    @inline()
  30. def toString(): String

    Permalink
    Definition Classes
    OptRef → Any
  31. def withFilter(p: (A) ⇒ Boolean): WithFilter[A]

    Permalink
    Annotations
    @inline()

Inherited from Serializable

Inherited from Serializable

Inherited from AnyVal

Inherited from Any

Ungrouped