net.liftweb.common

Box

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 Empty. It serves the same purpose as the Option class from Scala standard library but adds several features:

attributes: sealed abstract
go to: companion
linear super types: Product, Equals, AnyRef, Any
known subclasses: EmptyBox, Failure, ParamFailure, Full, Empty
self type: Box[A]
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
Impl.
  1. Concrete
  2. Abstract

Instance constructors

  1. new Box ()

Type Members

  1. class WithFilter extends AnyRef

    Play NiceLike with the Scala 2.

Value Members

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

    attributes: final
    definition classes: AnyRef
  2. def != (arg0: Any) : Boolean

    o != arg0 is the same as !(o == (arg0)).

    o != arg0 is the same as !(o == (arg0)).

    arg0

    the object to compare against this object for dis-equality.

    returns

    false if the receiver object is equivalent to the argument; true otherwise.

    attributes: final
    definition classes: Any
  3. def ## () : Int

    attributes: final
    definition classes: AnyRef → Any
  4. def $ (f: (Box[A]) ⇒ Unit) : Box[A]

    Alias for pass

    Alias for pass

  5. def $asInstanceOf [T0] () : T0

    attributes: final
    definition classes: AnyRef
  6. def $isInstanceOf [T0] () : Boolean

    attributes: final
    definition classes: AnyRef
  7. def == (arg0: AnyRef) : Boolean

    o == arg0 is the same as if (o eq null) arg0 eq null else o.equals(arg0).

    o == arg0 is the same as if (o eq null) arg0 eq null else o.equals(arg0).

    arg0

    the object to compare against this object for equality.

    returns

    true if the receiver object is equivalent to the argument; false otherwise.

    attributes: final
    definition classes: AnyRef
  8. def == (arg0: Any) : Boolean

    o == arg0 is the same as o.equals(arg0).

    o == arg0 is the same as o.equals(arg0).

    arg0

    the object to compare against this object for equality.

    returns

    true if the receiver object is equivalent to the argument; false otherwise.

    attributes: final
    definition classes: Any
  9. def === [B >: A] (to: B) : Boolean

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

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

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

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

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

    Transform an Empty 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

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

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

  13. def asInstanceOf [T0] : T0

    This method is used to cast the receiver object to be of type T0.

    This method is used to cast the receiver object to be of type T0.

    Note that the success of a cast at runtime is modulo Scala's erasure semantics. Therefore the expression1.asInstanceOf[String] will throw a ClassCastException at runtime, while the expressionList(1).asInstanceOf[List[String]] will not. In the latter example, because the type argument is erased as part of compilation it is not possible to check whether the contents of the list are of the requested typed.

    returns

    the receiver object.

    attributes: final
    definition classes: Any
  14. def canEqual (that: Any) : Boolean

    attributes: abstract
    definition classes: Equals
  15. 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.

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

  16. def clone () : AnyRef

    This method creates and returns a copy of the receiver object.

    This method creates and returns a copy of the receiver object.

    The default implementation of the clone method is platform dependent.

    returns

    a copy of the receiver object.

    attributes: protected
    definition classes: AnyRef
  17. 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.

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

    attributes: abstract
  18. def compoundFailMsg (msg: String) : Box[A]

    Alias for ?~!

    Alias for ?~!

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

    Equivalent to map(f).

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

  20. def elements : Iterator[A]

    Returns an Iterator over the value contained in this Box

    Returns an Iterator over the value contained in this Box

  21. def eq (arg0: AnyRef) : Boolean

    This method is used to test whether the argument (arg0) is a reference to the receiver object (this).

    This method is used to test whether the argument (arg0) is a reference to the receiver object (this).

    The eq method implements an [http://en.wikipedia.org/wiki/Equivalence_relation equivalence relation] on non-null instances of AnyRef: * It is reflexive: for any non-null instance x of type AnyRef, x.eq(x) returns true. * It is symmetric: for any non-null instances x and y of type AnyRef, x.eq(y) returns true if and only if y.eq(x) returns true. * It is transitive: for any non-null instances x, y, and z of type AnyRef if x.eq(y) returns true and y.eq(z) returns true, then x.eq(z) returns true.

    Additionally, the eq method has three other properties. * It is consistent: for any non-null instances x and y of type AnyRef, multiple invocations of x.eq(y) consistently returns true or consistently returns false. * For any non-null instance x of type AnyRef, x.eq(null) and null.eq(x) returns false. * null.eq(null) returns true.

    When overriding the equals or hashCode methods, it is important to ensure that their behavior is consistent with reference equality. Therefore, if two objects are references to each other (o1 eq o2), they should be equal to each other (o1 == o2) and they should hash to the same value (o1.hashCode == o2.hashCode).

    arg0

    the object to compare against this object for reference equality.

    returns

    true if the argument is a reference to the receiver object; false otherwise.

    attributes: final
    definition classes: AnyRef
  22. 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.@return true if the receiver object is equivalent to the argument; false otherwise. */

    definition classes: Box → Equals → AnyRef → Any
  23. 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

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

    Alias for ?~

    Alias for ?~

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

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

  27. def finalize () : Unit

    This method is called by the garbage collector on the receiver object when garbage collection determines that there are no more references to the object.

    This method is called by the garbage collector on the receiver object when garbage collection determines that there are no more references to the object.

    The details of when and if the finalize method are invoked, as well as the interaction between finalizeand non-local returns and exceptions, are all platform dependent.

    attributes: protected
    definition classes: AnyRef
  28. 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

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

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

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

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

    Returns a representation that corresponds to the dynamic class of the receiver object.

    Returns a representation that corresponds to the dynamic class of the receiver object.

    The nature of the representation is platform dependent.

    returns

    a representation that corresponds to the dynamic class of the receiver object.

    attributes: final
    definition classes: AnyRef
  31. def hashCode () : Int

    Returns a hash code value for the object.

    Returns a hash code value for the object.

    The default hashing algorithm is platform dependent.

    Note that it is allowed for two objects to have identical hash codes (o1.hashCode.equals(o2.hashCode)) yet not be equal (o1.equals(o2) returns false). A degenerate implementation could always return 0. However, it is required that if two objects are equal (o1.equals(o2) returns true) that they have identical hash codes (o1.hashCode.equals(o2.hashCode)). Therefore, when overriding this method, be sure to verify that the behavior is consistent with the equals method.

    returns

    the hash code value for the object.

    definition classes: AnyRef → Any
  32. 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

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

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

  34. def isEmpty : Boolean

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

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

    returns

    true if this Box contains no value

    attributes: abstract
  35. def isInstanceOf [T0] : Boolean

    This method is used to test whether the dynamic type of the receiver object is T0.

    This method is used to test whether the dynamic type of the receiver object is T0.

    Note that the test result of the test is modulo Scala's erasure semantics. Therefore the expression1.isInstanceOf[String] will return false, while the expression List(1).isInstanceOf[List[String]] will return true. In the latter example, because the type argument is erased as part of compilation it is not possible to check whether the contents of the list are of the requested typed.

    returns

    true if the receiver object is an instance of erasure of type T0; false otherwise.

    attributes: final
    definition classes: Any
  36. def iterator : Iterator[A]

    Returns an Iterator over the value contained in this Box

    Returns an Iterator over the value contained in this Box

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

    Get a Java Iterator from the Box

    Get a Java Iterator from the Box

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

  39. def ne (arg0: AnyRef) : Boolean

    o.ne(arg0) is the same as !(o.eq(arg0)).

    o.ne(arg0) is the same as !(o.eq(arg0)).

    arg0

    the object to compare against this object for reference dis-equality.

    returns

    false if the argument is not a reference to the receiver object; true otherwise.

    attributes: final
    definition classes: AnyRef
  40. def notify () : Unit

    Wakes up a single thread that is waiting on the receiver object's monitor.

    Wakes up a single thread that is waiting on the receiver object's monitor.

    attributes: final
    definition classes: AnyRef
  41. def notifyAll () : Unit

    Wakes up all threads that are waiting on the receiver object's monitor.

    Wakes up all threads that are waiting on the receiver object's monitor.

    attributes: final
    definition classes: AnyRef
  42. 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

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

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

    attributes: abstract
  45. def or [B >: A] (alternative: ⇒ Box[B]) : Box[B]

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

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

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

  47. def productArity : Int

    attributes: abstract
    definition classes: Product
  48. def productElement (n: Int) : Any

    attributes: abstract
    definition classes: Product
  49. def productElements : Iterator[Any]

    definition classes: Product
      deprecated:
    1. use productIterator instead

  50. def productIterator : Iterator[Any]

    definition classes: Product
  51. def productPrefix : String

    definition classes: Product
  52. 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

  53. def synchronized [T0] (arg0: T0) : T0

    attributes: final
    definition classes: AnyRef
  54. def toLeft [B] (right: ⇒ B) : Either[A, B]

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

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

  55. def toList : List[A]

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

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

  56. def toOption : Option[A]

    Returns the contents of this box in an Option if this is Full, or None if this is a failure or Empty.

    Returns the contents of this box in an Option if this is Full, or None if this is a failure or Empty.

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

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

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

  58. def toString () : String

    Returns a string representation of the object.

    Returns a string representation of the object.

    The default representation is platform dependent.

    returns

    a string representation of the object.

    definition classes: AnyRef → Any
  59. def wait () : Unit

    attributes: final
    definition classes: AnyRef
  60. def wait (arg0: Long, arg1: Int) : Unit

    attributes: final
    definition classes: AnyRef
  61. def wait (arg0: Long) : Unit

    attributes: final
    definition classes: AnyRef
  62. def withFilter (p: (A) ⇒ Boolean) : WithFilter

    Makes Box play better with Scala 2.

    Makes Box play better with Scala 2.8 for comprehensions

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

Inherited from Product

Inherited from Equals

Inherited from AnyRef

Inherited from Any