final class OptArg[+A] extends AnyVal with Serializable

OptArg is like Opt except it's intended to be used to type-safely express optional method/constructor parameters while at the same time avoiding having to explicitly wrap arguments when passing them (thanks to the implicit conversion from A to OptArg[A]). For example:

def takesMaybeString(str: OptArg[String] = OptArg.Empty) = ???

takesMaybeString()         // default empty value is used
takesMaybeString("string") // no explicit wrapping into OptArg required

Note that like Opt, OptArg assumes its underlying value to be non-null and null is translated into OptArg.Empty.
It is strongly recommended that OptArg type is used ONLY in signatures where implicit conversion A => OptArg[A] is intended to work. You should not use OptArg as a general-purpose "optional value" type - other types like Opt, NOpt and Option serve that purpose. For this reason OptArg deliberately does not have any "transforming" methods like map, flatMap, orElse, etc. Instead it's recommended that OptArg is converted to Opt, NOpt or Option as soon as possible (using toOpt, toNOpt and toOption methods).

Linear Supertypes
Serializable, Serializable, AnyVal, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. OptArg
  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 boxedOrNull[B >: Null](implicit boxing: Boxing[A, B]): B
    Annotations
    @inline()
  6. def contains[A1 >: A](elem: A1): Boolean
    Annotations
    @inline()
  7. def exists(p: (A) ⇒ Boolean): Boolean
    Annotations
    @inline()
  8. def fold[B](ifEmpty: ⇒ B)(f: (A) ⇒ B): B
    Annotations
    @inline()
  9. def forEmpty(sideEffect: ⇒ Unit): OptArg[A]

    Apply side effect only if OptArg is empty.

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

    sideEffect

    - code to be executed if optArg is empty

    returns

    the same optArg

    Annotations
    @inline()
    Example:
    1. captionOptArg.forEmpty(logger.warn("caption is empty")).foreach(setCaption)
  10. def forall(p: (A) ⇒ Boolean): Boolean
    Annotations
    @inline()
  11. def foreach[U](f: (A) ⇒ U): Unit
    Annotations
    @inline()
  12. def get: A
    Annotations
    @inline()
  13. def getClass(): Class[_ <: AnyVal]
    Definition Classes
    AnyVal → Any
  14. def getOrElse[B >: A](default: ⇒ B): B
    Annotations
    @inline()
  15. def isDefined: Boolean
    Annotations
    @inline()
  16. def isEmpty: Boolean
    Annotations
    @inline()
  17. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  18. def iterator: Iterator[A]
    Annotations
    @inline()
  19. def nonEmpty: Boolean
    Annotations
    @inline()
  20. def orNull[B >: A](implicit ev: <:<[Null, B]): B
    Annotations
    @inline()
  21. def toLeft[X](right: ⇒ X): Either[A, X]
    Annotations
    @inline()
  22. def toList: List[A]
    Annotations
    @inline()
  23. def toNOpt: NOpt[A]
    Annotations
    @inline()
  24. def toOpt: Opt[A]
    Annotations
    @inline()
  25. def toOptRef[B >: Null](implicit boxing: Boxing[A, B]): OptRef[B]
    Annotations
    @inline()
  26. def toOption: Option[A]
    Annotations
    @inline()
  27. def toRight[X](left: ⇒ X): Either[X, A]
    Annotations
    @inline()
  28. def toString(): String
    Definition Classes
    OptArg → Any

Inherited from Serializable

Inherited from Serializable

Inherited from AnyVal

Inherited from Any

Ungrouped