net.liftweb.common.Box

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


Companion: Box

Source: Box.scala(154)

Direct Known Subclasses

Full, EmptyBox,

Nested Classes

WithFilter,

 Constructors

def this

 Fields

elements.. def elements
Returns an Iterator over the value contained in this Box
Iterator[A]
isDefined.. def isDefined
Returns true if the box contains a value [details]
return
- true if this Box contains a value
Boolean
isEmpty.. abstract def isEmpty
Returns true if this Box contains no value (is Empty or Failure) [details]
return
- true if this Box contains no value
Boolean
iterator.. def iterator
Returns an Iterator over the value contained in this Box
Iterator[A]
open_!.. abstract def open_!
Return the value contained in this Box if it is full; throw an exception otherwise [details]
return
- the value contained in this Box if it is full; throw an exception otherwise
A
productArity.. abstract def productArity Int Product
productPrefix.. def productPrefix String Product
toList.. def toList
Returns a List of one element if this is Full, or an empty list if Empty
List[A]
toOption.. def toOption
Returns the contents of this box in an Option if this is Full, or None if this is a failure or Empty
Option[A]

 Methods

!=.. final def !=(arg0 : Object) Boolean AnyRef
!=.. final def !=(arg0 : Any) Boolean Any
==.. final def ==(arg0 : Any) Boolean Any
==.. final def ==(arg0 : Object) Boolean AnyRef
===.. def ===[B >: A](to : B)
Returns true if the value contained in this box is equal to the specified value
Boolean
?~.. def ?~(msg : String)
Transform an Empty to a Failure with the specified message [details]
param
msg - the failure message
return
- a Failure with the message if this Box is Empty
Box[A]
?~!.. def ?~!(msg : String)
Transform an Empty to a Failure with the specified message and chain the new Failure to any previous Failure represented by this Box [details]
param
msg - the failure message
return
- a Failure with the message if this Box is an Empty Box. Chain the messages if it is already a Failure
Box[A]
asA.. def asA[B](implicit m : Manifest[B])
Return a Full[B] if the contents of this Box is of type B, otherwise return Empty
Box[B]
asInstanceOf.. final def asInstanceOf[T0] T0 Any
choice.. def choice[B](f1 : (A) => Box[B])(alternative : => Box[B])
Apply the function f1 to the contents of this Box if available; if this is Empty return the specified alternative
Box[B]
clone.. protected def clone Object AnyRef
collect.. abstract def collect[B](pf : PartialFunction[A, B])
If the partial function is defined at the current Box's value apply the partial function
Box[B]
compoundFailMsg.. def compoundFailMsg(msg : String)
Alias for ?~!
Box[A]
dmap.. def dmap[B](dflt : => B)(f : (A) => B)
Equivalent to map(f) [details]
or(Full(dflt)).open_!
B
eq.. final def eq(arg0 : Object) Boolean AnyRef
equals.. override def equals(other : Any)
Determines equality based upon the contents of this Box instead of the box itself [details]
For Full and Empty, this has the expected behavior. Equality in terms of Failure checks for equivalence of failure causes.
Boolean
exists.. def exists(func : (A) => Boolean)
Determine whether this Box contains a value which satisfies the specified predicate [details]
return
- true if this Box's value satisfies the specified predicate
Boolean
failMsg.. def failMsg(msg : String)
Alias for ?~
Box[A]
filter.. def filter(p : (A) => Boolean)
Return this Box if it contains a value satisfying the specified predicate; Empty otherwise [details]
return
- this Box if it contains a value satisfying the specified predicate; Empty otherwise
Box[A]
filterMsg.. def filterMsg(msg : String)(p : (A) => Boolean)
Filter this box on the specified predicate, returning a Failure with the specified message if the predicate is not satisfied [details]
param
p - a predicate
msg - the failure message
return
- a Failure with the message if the predicate is not satisfied by the value contained in this Box
Box[A]
finalize.. protected def finalize Unit AnyRef
flatMap.. def flatMap[B](f : (A) => 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 [details]
return
- the modified Box or Empty
Box[B]
foreach.. def foreach[U](f : (A) => U)
Perform a side effect by calling the specified function with the value contained in this box
Unit
getClass.. final def getClass Class[Any] AnyRef
hashCode.. def hashCode Int AnyRef
isA.. def isA[B](cls : Class[B])
Return a Full[B] if the contents of this Box is an instance of the specified class, otherwise return Empty
Box[B]
isInstanceOf.. final def isInstanceOf[T0] Boolean Any
map.. def map[B](f : (A) => 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 [details]
return
- the modified Box or Empty
Box[B]
ne.. final def ne(arg0 : Object) Boolean AnyRef
notify.. final def notify Unit AnyRef
notifyAll.. final def notifyAll Unit AnyRef
openOr.. def openOr[B >: A](default : => B)
Return the value contained in this Box if it is full; otherwise return the specified default [details]
return
- the value contained in this Box if it is full; otherwise return the specified default
B
or.. def or[B >: A](alternative : => Box[B])
Return this Box if Full, or the specified alternative if this is Empty
Box[B]
pass.. def pass(f : (Box[A]) => Unit)
Perform a side effect by passing this Box to the specified function and return this Box unmodified [details]
return
- this Box
Box[A]
productElement.. abstract def productElement(arg0 : Int) Any Product
run.. def run[T](in : T)(f : (T, A) => T)
This method calls the specified function with the value contained in this Box [details]
return
- the result of the function or a default value
T
synchronized.. final def synchronized[T0](arg0 : T0) T0 AnyRef
toLeft.. def toLeft[B](right : => 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
Either[A, B]
toRight.. def toRight[B](left : => B)
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
Either[B, A]
toString.. def toString String AnyRef
wait.. final def wait(arg0 : Long, arg1 : Int) Unit AnyRef
wait.. final def wait Unit AnyRef
wait.. final def wait(arg0 : Long) Unit AnyRef
withFilter.. def withFilter(p : (A) => Boolean)
Makes Box play better with Scala 2 [details]
8 for comprehensions
WithFilter
~>.. def ~>[T](errorCode : T)
Transform an Empty to a ParamFailure with the specified typesafe parameter [details]
param
errorCode - a value indicating the error
return
- a ParamFailure with the specified value
Box[A]
Copyright (c) 2006-2010 WorldWide Conferencing, LLC. All Rights Reserved.