object Box extends BoxTrait with Tryo with Serializable

The Box companion object provides methods to create a Box from:

It also provides implicit methods to transform Option to Box, Box to Iterable, and Box to Option.

Linear Supertypes
Serializable, Serializable, Tryo, BoxTrait, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Box
  2. Serializable
  3. Serializable
  4. Tryo
  5. BoxTrait
  6. AnyRef
  7. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. implicit final class ListOfBoxes [T] extends AnyVal

    Helper class to provide an easy way for converting a List[Box[T]] into a Box[List[T]].

Value Members

  1. def !![T](in: T): Box[T]

    Alias for legacyNullTest.

    Alias for legacyNullTest.

    Definition Classes
    BoxTrait
  2. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  3. final def ##(): Int
    Definition Classes
    AnyRef → Any
  4. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  5. def apply[InType, OutType](value: InType)(pf: PartialFunction[InType, OutType]): Box[OutType]

    Apply the specified PartialFunction to the specified value and return the result in a Full; if the pf is not defined at that point return Empty.

    Apply the specified PartialFunction to the specified value and return the result in a Full; if the pf is not defined at that point return Empty.

    value

    The value to transform.

    pf

    The partial function to use to transform the value.

    returns

    A Full containing the transformed value if pf.isDefinedAt(value) and Empty otherwise.

    Definition Classes
    BoxTrait
  6. def apply[InType, OutType](pf: PartialFunction[InType, OutType])(value: InType): Box[OutType]

    Apply the specified PartialFunction to the specified value and return the result in a Full; if the pf is not defined at that point return Empty.

    Apply the specified PartialFunction to the specified value and return the result in a Full; if the pf is not defined at that point return Empty.

    pf

    The partial function to use to transform the value.

    value

    The value to transform.

    returns

    A Full containing the transformed value if pf.isDefinedAt(value) and Empty otherwise.

    Definition Classes
    BoxTrait
  7. def apply[T](in: List[T]): Box[T]

    Transform a List with zero or more elements to a Box, losing all but the first element if there are more than one.

    Transform a List with zero or more elements to a Box, 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 and Empty otherwise.

    Definition Classes
    BoxTrait
  8. def apply[T](in: Box[T]): Box[T]

    Create a Box from the specified Box, checking for null.

    Create a Box from the specified Box, checking for null.

    returns

    Full(in) if in is a Full box and its value is non-null, Empty otherwise.

    Definition Classes
    BoxTrait
  9. def apply[T](in: Option[T]): Box[T]

    Create a Box from the specified Option.

    Create a Box from the specified Option.

    returns

    Full with the contents if the Option is Some and Empty otherwise.

    Definition Classes
    BoxTrait
  10. def asA[B](in: T forSome {type T})(implicit m: Manifest[B]): Box[B]

    Create a Full box containing the specified value if in is of type B and Empty otherwise.

    Create a Full box containing the specified value if in is of type B and Empty otherwise.

    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
  11. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  12. implicit def box2Iterable[T](in: Box[T]): Iterable[T]

    This implicit transformation allows one to use a Box as an Iterable of zero or one elements.

    This implicit transformation allows one to use a Box as an Iterable of zero or one elements.

    returns

    A single-element List with the contents if the box is Full and Nil otherwise.

    Definition Classes
    BoxTrait
  13. implicit def box2Option[T](in: Box[T]): Option[T]

    This implicit transformation allows one to use a Box as an Option.

    This implicit transformation allows one to use a Box as an Option.

    Note that Box implements get specifically to avoid usage of .get on Box instances. Boxes should be opened using openOrThrowException and their contents compared using == Full(expectedValue).

    returns

    Some with the contents if the box is Full and None otherwise.

    Definition Classes
    BoxTrait
  14. def clone(): AnyRef
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  15. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  16. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  17. def finalize(): Unit
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  18. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
  19. def hashCode(): Int
    Definition Classes
    AnyRef → Any
  20. def isA[A, B](in: A, clz: Class[B]): Box[B]

    Create a Full box containing the specified value if in is an instance of the specified class clz and Empty otherwise.

    Create a Full box containing the specified value if in is an instance of the specified class clz and Empty otherwise.

    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
  21. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  22. def legacyNullTest[T](in: T): Box[T]

    This method allows one to encapsulate any object in a Box in a null-safe manner, converting null values to Empty.

    This method allows one to encapsulate any object in a Box in a null-safe manner, converting null values to Empty.

    returns

    Full if in is not null and Empty otherwise.

    Definition Classes
    BoxTrait
  23. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  24. final def notify(): Unit
    Definition Classes
    AnyRef
  25. final def notifyAll(): Unit
    Definition Classes
    AnyRef
  26. implicit def option2Box[T](in: Option[T]): Box[T]

    This implicit transformation allows one to use an Option as a Box.

    This implicit transformation allows one to use an Option as a Box.

    returns

    Full with the contents if the Option is Some and Empty otherwise.

    Definition Classes
    BoxTrait
  27. val primitiveMap: Map[Class[_], Class[_]]
    Definition Classes
    BoxTrait
  28. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  29. def toString(): String
    Definition Classes
    AnyRef → Any
  30. 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
  31. 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
  32. 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
  33. 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
  34. 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

  35. 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
  36. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  37. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  38. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Deprecated Value Members

  1. val primativeMap: Map[Class[_], Class[_]]
    Definition Classes
    BoxTrait
    Annotations
    @deprecated
    Deprecated

    (Since version 3.0) Use the correctly-spelled primitiveMap instead.

Inherited from Serializable

Inherited from Serializable

Inherited from Tryo

Inherited from BoxTrait

Inherited from AnyRef

Inherited from Any

Ungrouped