net.liftweb.common

Box

sealed abstract class Box[+A] extends Product

The Box class is a container which is able to declare if it is Full (containing a single non-null value) or EmptyBox. An EmptyBox, or empty, can be the Empty singleton, Failure or ParamFailure. Failure and ParamFailure contain information about why the Box is empty including exception information, chained Failures and a String. It serves a similar purpose to the Option class from Scala standard library but adds several features:

Self Type
Box[A]
Annotations
@serializable()
Linear Supertypes
Product, Equals, AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Hide All
  2. Show all
  1. Box
  2. Product
  3. Equals
  4. AnyRef
  5. Any
Visibility
  1. Public
  2. All

Instance Constructors

  1. new Box()

Type Members

  1. class WithFilter extends AnyRef

    Play NiceLike with the Scala 2.

Abstract Value Members

  1. abstract def canEqual(that: Any): Boolean

    Definition Classes
    Equals
  2. abstract def collect[B](pf: PartialFunction[A, B]): Box[B]

    If the partial function is defined at the current Box's value apply the partial function.

  3. abstract def isEmpty: Boolean

    Returns true if this Box contains no value (is Empty or Failure or ParamFailure)

    Returns true if this Box contains no value (is Empty or Failure or ParamFailure)

    returns

    true if this Box contains no value

  4. abstract def open_!: A

    Return the value contained in this Box if it is Full; throw an exception otherwise.

    Return the value contained in this Box if it is Full; throw an exception otherwise. The method has a '!' in its name. This means "don't use it unless you are 100% sure that the Box is Full and you should probably comment your code with the explanation of the guaranty. The better case for extracting the value out of a Box can be found at http://lift.la/scala-option-lift-box-and-how-to-make-your-co

    returns

    the value contained in this Box if it is full; throw an exception otherwise

  5. abstract def productArity: Int

    Definition Classes
    Product
  6. abstract def productElement(n: Int): Any

    Definition Classes
    Product

Concrete Value Members

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

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

    Definition Classes
    AnyRef → Any
  4. def $(f: (Box[A]) ⇒ Unit): Box[A]

    Alias for pass

  5. final def ==(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  6. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  7. def ===[B >: A](to: B): Boolean

    Returns true if the value contained in this box is equal to the specified value.

  8. def ?~(msg: String): Box[A]

    Transform an Empty to a Failure with the specified message.

    Transform an Empty to a Failure with the specified message.

    msg

    the failure message

    returns

    a Failure with the message if this Box is Empty

  9. def ?~!(msg: String): Box[A]

    Transform an EmptyBox to a Failure with the specified message and chain the new Failure to any previous Failure represented by this Box.

    Transform an EmptyBox to a Failure with the specified message and chain the new Failure to any previous Failure represented by this Box.

    msg

    the failure message

    returns

    a Failure with the message if this Box is an Empty Box. Chain the messages if it is already a Failure

  10. def asA[B](implicit m: Manifest[B]): Box[B]

    Return a Full[B] if the contents of this Box is of type B, otherwise return Empty

  11. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  12. def choice[B](f1: (A) ⇒ Box[B])(alternative: ⇒ Box[B]): Box[B]

    Apply the function f1 to the contents of this Box if available; if this is empty return the specified alternative.

  13. def clone(): AnyRef

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  14. def compoundFailMsg(msg: String): Box[A]

    Alias for ?~!

  15. def dmap[B](dflt: ⇒ B)(f: (A) ⇒ B): B

    Equivalent to map(f).

    Equivalent to map(f).openOr(Full(dflt))

  16. def elements: Iterator[A]

    Returns an Iterator over the value contained in this Box

  17. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  18. def equals(other: Any): Boolean

    Determines equality based upon the contents of this Box instead of the box itself.

    Determines equality based upon the contents of this Box instead of the box itself. For Full and Empty, this has the expected behavior. Equality in terms of Failure checks for equivalence of failure causes.

    Definition Classes
    Box → Equals → AnyRef → Any
  19. def exists(func: (A) ⇒ Boolean): Boolean

    Determine whether this Box contains a value which satisfies the specified predicate

    Determine whether this Box contains a value which satisfies the specified predicate

    returns

    true if this Box's value satisfies the specified predicate

  20. def failMsg(msg: String): Box[A]

    Alias for ?~

  21. def filter(p: (A) ⇒ Boolean): Box[A]

    Return this Box if it contains a value satisfying the specified predicate; Empty otherwise

    Return this Box if it contains a value satisfying the specified predicate; Empty otherwise

    returns

    this Box if it contains a value satisfying the specified predicate; Empty otherwise

  22. def filterMsg(msg: String)(p: (A) ⇒ Boolean): Box[A]

    Filter this box on the specified predicate, returning a Failure with the specified message if the predicate is not satisfied.

    Filter this box on the specified predicate, returning a Failure with the specified message if the predicate is not satisfied.

    msg

    the failure message

    p

    a predicate

    returns

    a Failure with the message if the predicate is not satisfied by the value contained in this Box

  23. def filterNot(f: (A) ⇒ Boolean): Box[A]

    Creates a Box if the current Box is Full and the value does not satisfy the predicate, f.

    Creates a Box if the current Box is Full and the value does not satisfy the predicate, f.

    f

    the predicate used to test value.

  24. def finalize(): Unit

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  25. def flatMap[B](f: (A) ⇒ Box[B]): Box[B]

    Apply a function returning a Box to the value contained in this Box if it exists and return the result, or empty otherwise.

    Apply a function returning a Box to the value contained in this Box if it exists and return the result, or empty otherwise.

    returns

    the modified Box or empty

  26. def foreach[U](f: (A) ⇒ U): Unit

    Perform a side effect by calling the specified function with the value contained in this box.

  27. final def getClass(): java.lang.Class[_]

    Definition Classes
    AnyRef → Any
  28. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  29. def isA[B](cls: Class[B]): Box[B]

    Return a Full[B] if the contents of this Box is an instance of the specified class, otherwise return Empty

  30. def isDefined: Boolean

    Returns true if the box contains a value.

    Returns true if the box contains a value.

    returns

    true if this Box contains a value

  31. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  32. def iterator: Iterator[A]

    Returns an Iterator over the value contained in this Box

  33. def javaIterator[B >: A]: Iterator[B]

    Get a Java Iterator from the Box

  34. def map[B](f: (A) ⇒ B): Box[B]

    Apply a function to the value contained in this Box if it exists and return a new Box containing the result, or empty otherwise.

    Apply a function to the value contained in this Box if it exists and return a new Box containing the result, or empty otherwise.

    returns

    the modified Box or empty

  35. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  36. final def notify(): Unit

    Definition Classes
    AnyRef
  37. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  38. def openOr[B >: A](default: ⇒ B): B

    Return the value contained in this Box if it is full; otherwise return the specified default

    Return the value contained in this Box if it is full; otherwise return the specified default

    returns

    the value contained in this Box if it is full; otherwise return the specified default

  39. def openTheBox: A

    Return the value contained in this Box if it is Full; throw an exception otherwise.

    Return the value contained in this Box if it is Full; throw an exception otherwise. This means "don't use it unless you are 100% sure that the Box is Full and you should probably comment your code with the explanation of the guaranty. The better case for extracting the value out of a Box can be found at http://lift.la/scala-option-lift-box-and-how-to-make-your-co

    returns

    the value contained in this Box if it is full; throw an exception otherwise

  40. def or[B >: A](alternative: ⇒ Box[B]): Box[B]

    Return this Box if Full, or the specified alternative if this is empty

  41. def pass(f: (Box[A]) ⇒ Unit): Box[A]

    Perform a side effect by passing this Box to the specified function and return this Box unmodified.

    Perform a side effect by passing this Box to the specified function and return this Box unmodified.

    returns

    this Box

  42. def productIterator: Iterator[Any]

    Definition Classes
    Product
  43. def productPrefix: String

    Definition Classes
    Product
  44. def run[T](in: T)(f: (T, A) ⇒ T): T

    This method calls the specified function with the value contained in this Box

    This method calls the specified function with the value contained in this Box

    returns

    the result of the function or a default value

  45. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  46. def toLeft[B](right: ⇒ B): Either[A, B]

    An Either that is a Right with the given argument right if this is empty, or a Left if this is Fill with the Box's value

  47. def toList: List[A]

    Returns a List of one element if this is Full, or an empty list if empty.

  48. def toOption: Option[A]

    Returns the contents of this box in an Option if this is Full, or None if this is a empty (Empty, Failure or ParamFailure)

  49. def toRight[B](left: ⇒ B): Either[B, A]

    An Either that is a Left with the given argument left if this is empty, or a Right if this Full with the Box's value.

  50. def toString(): String

    Definition Classes
    AnyRef → Any
  51. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()
  52. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()
  53. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()
  54. def withFilter(p: (A) ⇒ Boolean): WithFilter

    Makes Box play better with Scala 2.

    Makes Box play better with Scala 2.8 for comprehensions

  55. def ~>[T](errorCode: T): Box[A]

    Transform an Empty to a ParamFailure with the specified typesafe parameter.

    Transform an Empty to a ParamFailure with the specified typesafe parameter.

    errorCode

    a value indicating the error

    returns

    a ParamFailure with the specified value

Deprecated Value Members

  1. def productElements: Iterator[Any]

    Definition Classes
    Product
    Annotations
    @deprecated
    Deprecated

    (Since version 2.8.0) use productIterator instead

Inherited from Product

Inherited from Equals

Inherited from AnyRef

Inherited from Any