object Box extends BoxTrait with Tryo with Serializable
The Box companion object provides methods to create a Box from:
- an
Option - a
List - any
AnyRefobject, convertingnulltoEmptyand anything else to aFullwith the given object
It also provides implicit methods to transform Option to Box, Box to
Iterable, and Box to Option.
- Alphabetic
- By Inheritance
- Box
- Serializable
- Serializable
- Tryo
- BoxTrait
- OptionImplicits
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Type Members
-
implicit final
class
ListOfBoxes[T] extends AnyVal
Helper class to provide an easy way for converting a
List[Box[T]]into aBox[List[T]].
Value Members
-
def
!: Box[T]
Alias for
legacyNullTest.Alias for
legacyNullTest.- Definition Classes
- BoxTrait
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
apply[InType, OutType](value: InType)(pf: PartialFunction[InType, OutType]): Box[OutType]
Apply the specified
PartialFunctionto the specifiedvalueand return the result in aFull; if thepfis not defined at that point returnEmpty.Apply the specified
PartialFunctionto the specifiedvalueand return the result in aFull; if thepfis not defined at that point returnEmpty.- value
The value to transform.
- pf
The partial function to use to transform the value.
- returns
A
Fullcontaining the transformed value ifpf.isDefinedAt(value)andEmptyotherwise.
- Definition Classes
- BoxTrait
-
def
apply[InType, OutType](pf: PartialFunction[InType, OutType])(value: InType): Box[OutType]
Apply the specified
PartialFunctionto the specifiedvalueand return the result in aFull; if thepfis not defined at that point returnEmpty.Apply the specified
PartialFunctionto the specifiedvalueand return the result in aFull; if thepfis not defined at that point returnEmpty.- pf
The partial function to use to transform the value.
- value
The value to transform.
- returns
A
Fullcontaining the transformed value ifpf.isDefinedAt(value)andEmptyotherwise.
- Definition Classes
- BoxTrait
-
def
apply[T](in: List[T]): Box[T]
Transform a
Listwith zero or more elements to aBox, losing all but the first element if there are more than one.Transform a
Listwith zero or more elements to aBox, losing all but the first element if there are more than one.- returns
Full(x)with the head of the list if it contains at least one element andEmptyotherwise.
- Definition Classes
- BoxTrait
-
def
apply[T](in: Box[T]): Box[T]
Create a
Boxfrom the specifiedBox, checking fornull.Create a
Boxfrom the specifiedBox, checking fornull.- returns
Full(in)ifinis aFullbox and its value is non-null,Emptyotherwise.
- Definition Classes
- BoxTrait
-
def
apply[T](in: Option[T]): Box[T]
Create a
Boxfrom the specifiedOption.Create a
Boxfrom the specifiedOption.- returns
Fullwith the contents if theOptionisSomeandEmptyotherwise.
- Definition Classes
- BoxTrait
-
def
asA[B](in: T forSome {type T})(implicit m: Manifest[B]): Box[B]
Create a
Fullbox containing the specified value ifinis of typeBandEmptyotherwise.Create a
Fullbox containing the specified value ifinis of typeBandEmptyotherwise.For example:
scala> Box.asA[Int]("boom") res0: net.liftweb.common.Box[Int] = Empty scala> Box.asA[Int](5) res1: net.liftweb.common.Box[Int] = Full(5)
- Definition Classes
- BoxTrait
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
implicit
def
box2Iterable[T](in: Box[T]): Iterable[T]
This implicit transformation allows one to use a
Boxas anIterableof zero or one elements. -
implicit
def
box2Option[T](in: Box[T]): Option[T]
This implicit transformation allows one to use a
Boxas anOption.This implicit transformation allows one to use a
Boxas anOption.Note that
Boximplementsgetspecifically to avoid usage of.getonBoxinstances. Boxes should be opened usingopenOrThrowExceptionand their contents compared using== Full(expectedValue).- returns
Somewith the contents if the box isFullandNoneotherwise.
- Definition Classes
- OptionImplicits
-
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
isA[A, B](in: A, clz: Class[B]): Box[B]
Create a
Fullbox containing the specified value ifinis an instance of the specified classclzandEmptyotherwise.Create a
Fullbox containing the specified value ifinis an instance of the specified classclzandEmptyotherwise.This is basically a Java-friendly version of
asA, which you should prefer when using Scala.For example:
scala> Box.isA("boom", classOf[Int]) res0: net.liftweb.common.Box[Int] = Empty scala> Box.isA(5, classOf[Int]) res1: net.liftweb.common.Box[Int] = Full(5)
- Definition Classes
- BoxTrait
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
legacyNullTest[T](in: T): Box[T]
This method allows one to encapsulate any object in a Box in a null-safe manner, converting
nullvalues toEmpty.This method allows one to encapsulate any object in a Box in a null-safe manner, converting
nullvalues toEmpty.- returns
Fullifinis not null andEmptyotherwise.
- Definition Classes
- BoxTrait
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
implicit
def
option2Box[T](in: Option[T]): Box[T]
This implicit transformation allows one to use an
Optionas aBox.This implicit transformation allows one to use an
Optionas aBox.- returns
Fullwith the contents if theOptionisSomeandEmptyotherwise.
- Definition Classes
- OptionImplicits
-
val
primitiveMap: Map[Class[_], Class[_]]
- Definition Classes
- BoxTrait
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
def
tryo[T](ignore: Class[_])(f: ⇒ T): Box[T]
Wraps a "try" block around the function f.
Wraps a "try" block around the function f. Takes only one Class of exception to ignore
- ignore
- a single exception classes to ignore. A thrown exception will be ignored if it is assignable from this class.
- f
- the block of code to evaluate
- returns
- Full(result of the evaluation of f) if f doesn't throw any exception
- a Failure if f throws an exception
- Empty if the exception class is in the ignore list
- Definition Classes
- Tryo
-
def
tryo[T](ignore: List[Class[_]])(f: ⇒ T): Box[T]
Wraps a "try" block around the function f
Wraps a "try" block around the function f
- ignore
- a list of exception classes to ignore. A thrown exception will be ignored if it is assignable from one of the exception classes in the list
- f
- the block of code to evaluate
- returns
- Full(result of the evaluation of f) if f doesn't throw any exception
- a Failure if f throws an exception
- Empty if the exception class is in the ignore list
- Definition Classes
- Tryo
-
def
tryo[T](onError: (Throwable) ⇒ Unit)(f: ⇒ T): Box[T]
Wraps a "try" block around the function f and trigger a callback function if an exception is thrown
Wraps a "try" block around the function f and trigger a callback function if an exception is thrown
- onError
- an optional callback function that will use the thrown exception as a parameter
- f
- the block of code to evaluate
- returns
- Full(result of the evaluation of f) if f doesn't throw any exception
- a Failure if f throws an exception
- Definition Classes
- Tryo
-
def
tryo[T](f: ⇒ T): Box[T]
Wraps a "try" block around the function f
Wraps a "try" block around the function f
- f
- the block of code to evaluate
- returns
- Full(result of the evaluation of f) if f doesn't throw any exception
- a Failure if f throws an exception
- Definition Classes
- Tryo
-
def
tryo[T](handler: PartialFunction[Throwable, T], f: ⇒ T): Box[T]
Wraps a "try" block around the function f.
Wraps a "try" block around the function f. If f throws an exception that is in the domain of the handler PF, the handler will be invoked on the exception. Otherwise the exception is wrapped into a Failure.
- handler
- A partial function that handles exceptions
- f
- the block of code to evaluate
- returns
- Full(result of the evaluation of f) if f doesn't throw any exception
- a Failure if f throws an exception
- Definition Classes
- Tryo
- See also
net.liftweb.common.Failure
-
def
tryo[T](ignore: List[Class[_]], onError: Box[(Throwable) ⇒ Unit])(f: ⇒ T): Box[T]
Wraps a "try" block around the function f.
Wraps a "try" block around the function f. If f throws an exception with its class in the 'ignore' list or if 'ignore' is null or an empty list, ignore the exception and return None.
- ignore
- a list of exception classes to ignore. A thrown exception will be ignored if it is assignable from one of the exception classes in the list
- onError
- an optional callback function that will use the thrown exception as a parameter
- f
- the block of code to evaluate
- returns
- Full(result of the evaluation of f) if f doesn't throw any exception
- a Failure if f throws an exception
- Empty if the exception class is in the ignore list
- Definition Classes
- Tryo
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()