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).

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
    Definition Classes
    Any
  2. final def ##(): Int
    Definition Classes
    Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    Any
  4. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. def collect[B >: Null](pf: PartialFunction[A, B]): OptRef[B]
    Annotations
    @inline()
  6. def contains[A1 >: A](elem: A1): Boolean
    Annotations
    @inline()
  7. def exists(p: (A) ⇒ Boolean): Boolean
    Annotations
    @inline()
  8. def filter(p: (A) ⇒ Boolean): OptRef[A]
    Annotations
    @inline()
  9. def filterNot(p: (A) ⇒ Boolean): OptRef[A]
    Annotations
    @inline()
  10. def flatMap[B >: Null](f: (A) ⇒ OptRef[B]): OptRef[B]
    Annotations
    @inline()
  11. def fold[B](ifEmpty: ⇒ B)(f: (A) ⇒ B): B
    Annotations
    @inline()
  12. def forEmpty(sideEffect: ⇒ Unit): OptRef[A]

    Apply side effect only if OptRef is empty.

    Apply side effect only if OptRef is empty. It's a bit like foreach for OptRef.Empty

    sideEffect

    - code to be executed if optRef is empty

    returns

    the same optRef

    Annotations
    @inline()
    Example:
    1. captionOptRef.forEmpty(logger.warn("caption is empty")).foreach(setCaption)
  13. def forall(p: (A) ⇒ Boolean): Boolean
    Annotations
    @inline()
  14. def foreach[U](f: (A) ⇒ U): Unit
    Annotations
    @inline()
  15. def get: A
    Annotations
    @inline()
  16. def getClass(): Class[_ <: AnyVal]
    Definition Classes
    AnyVal → Any
  17. def getOrElse[B >: A](default: ⇒ B): B
    Annotations
    @inline()
  18. def isDefined: Boolean
    Annotations
    @inline()
  19. def isEmpty: Boolean
    Annotations
    @inline()
  20. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  21. def iterator: Iterator[A]
    Annotations
    @inline()
  22. def map[B >: Null](f: (A) ⇒ B): OptRef[B]
    Annotations
    @inline()
  23. def nonEmpty: Boolean
    Annotations
    @inline()
  24. def orElse[B >: A](alternative: ⇒ OptRef[B]): OptRef[B]
    Annotations
    @inline()
  25. def orNull[B >: A](implicit ev: <:<[Null, B]): B
    Annotations
    @inline()
  26. def toLeft[X](right: ⇒ X): Either[A, X]
    Annotations
    @inline()
  27. def toList: List[A]
    Annotations
    @inline()
  28. def toNOpt: NOpt[A]
    Annotations
    @inline()
  29. def toOpt: Opt[A]
    Annotations
    @inline()
  30. def toOptArg: OptArg[A]
    Annotations
    @inline()
  31. def toOption: Option[A]
    Annotations
    @inline()
  32. def toRight[X](left: ⇒ X): Either[X, A]
    Annotations
    @inline()
  33. def toString(): String
    Definition Classes
    OptRef → Any
  34. def withFilter(p: (A) ⇒ Boolean): WithFilter[A]
    Annotations
    @inline()
  35. def zip[B >: Null](that: OptRef[B]): OptRef[(A, B)]
    Annotations
    @inline()

Inherited from Serializable

Inherited from Serializable

Inherited from AnyVal

Inherited from Any

Ungrouped