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
Ordering
- Alphabetic
- By Inheritance
Inherited
- OptRef
- Serializable
- Serializable
- AnyVal
- Any
- Hide All
- Show All
Visibility
- Public
- All
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- Any
-
final
def
##(): Int
- Definition Classes
- Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- Any
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
collect[B >: Null](pf: PartialFunction[A, B]): OptRef[B]
- Annotations
- @inline()
-
def
contains[A1 >: A](elem: A1): Boolean
- Annotations
- @inline()
-
def
exists(p: (A) ⇒ Boolean): Boolean
- Annotations
- @inline()
-
def
filter(p: (A) ⇒ Boolean): OptRef[A]
- Annotations
- @inline()
-
def
filterNot(p: (A) ⇒ Boolean): OptRef[A]
- Annotations
- @inline()
-
def
flatMap[B >: Null](f: (A) ⇒ OptRef[B]): OptRef[B]
- Annotations
- @inline()
-
def
fold[B >: Null](ifEmpty: ⇒ B)(f: (A) ⇒ B): B
- Annotations
- @inline()
-
def
forall(p: (A) ⇒ Boolean): Boolean
- Annotations
- @inline()
-
def
foreach[U](f: (A) ⇒ U): Unit
- Annotations
- @inline()
-
def
get: A
- Annotations
- @inline()
-
def
getClass(): Class[_ <: AnyVal]
- Definition Classes
- AnyVal → Any
-
def
getOrElse[B >: A](default: ⇒ B): B
- Annotations
- @inline()
-
def
isDefined: Boolean
- Annotations
- @inline()
-
def
isEmpty: Boolean
- Annotations
- @inline()
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
iterator: Iterator[A]
- Annotations
- @inline()
-
def
map[B >: Null](f: (A) ⇒ B): OptRef[B]
- Annotations
- @inline()
-
def
nonEmpty: Boolean
- Annotations
- @inline()
-
def
orElse[B >: A](alternative: ⇒ OptRef[B]): OptRef[B]
- Annotations
- @inline()
-
def
orNull[B >: A](implicit ev: <:<[Null, B]): B
- Annotations
- @inline()
-
def
toLeft[X](right: ⇒ X): Either[A, X]
- Annotations
- @inline()
-
def
toList: List[A]
- Annotations
- @inline()
-
def
toOpt: Opt[A]
- Annotations
- @inline()
-
def
toOption: Option[A]
- Annotations
- @inline()
-
def
toRight[X](left: ⇒ X): Either[X, A]
- Annotations
- @inline()
-
def
toString(): String
- Definition Classes
- OptRef → Any
-
def
withFilter(p: (A) ⇒ Boolean): WithFilter[A]
- Annotations
- @inline()