Play NiceLike with the Scala 2.
o != arg0
is the same as !(o == (arg0))
.
o != arg0
is the same as !(o == (arg0))
.
the object to compare against this object for dis-equality.
false
if the receiver object is equivalent to the argument; true
otherwise.
Alias for pass
Alias for pass
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)
.
the object to compare against this object for equality.
true
if the receiver object is equivalent to the argument; false
otherwise.
o == arg0
is the same as o.equals(arg0)
.
o == arg0
is the same as o.equals(arg0)
.
the object to compare against this object for equality.
true
if the receiver object is equivalent to the argument; false
otherwise.
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.
Transform an Empty to a Failure with the specified message.
Transform an Empty to a Failure with the specified message.
the failure message
a Failure with the message if this Box is Empty
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.
the failure message
a Failure with the message if this Box is an Empty Box. Chain the messages if it is already a Failure
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
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.
the receiver object.
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.
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.
a copy of the receiver object.
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.
Alias for ?~!
Alias for ?~!
Equivalent to map(f).
Equivalent to map(f).openOr(Full(dflt))
Returns an Iterator over the value contained in this Box
Returns an Iterator over the value contained in this Box
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
).
the object to compare against this object for reference equality.
true
if the argument is a reference to the receiver object; false
otherwise.
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. */
Determine whether this Box contains a value which satisfies the specified predicate
Determine whether this Box contains a value which satisfies the specified predicate
true if this Box's value satisfies the specified predicate
Alias for ?~
Alias for ?~
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
this Box if it contains a value satisfying the specified predicate; Empty otherwise
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.
the failure message
a predicate
a Failure with the message if the predicate is not satisfied by the value contained in this Box
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 finalize
and non-local returns and exceptions, are all platform dependent.
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.
the modified Box or Empty
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.
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.
a representation that corresponds to the dynamic class of the receiver object.
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.
the hash code value for the object.
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
Returns true if the box contains a value.
Returns true if the box contains a value.
true if this Box contains a value
Returns true if this Box contains no value (is Empty or Failure)
Returns true if this Box contains no value (is Empty or Failure)
true if this Box contains no value
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.
true
if the receiver object is an instance of erasure of type T0
; false
otherwise.
Returns an Iterator over the value contained in this Box
Returns an Iterator over the value contained in this Box
Get a Java Iterator from the Box
Get a Java Iterator from the Box
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.
the modified Box or Empty
o.ne(arg0)
is the same as !(o.eq(arg0))
.
o.ne(arg0)
is the same as !(o.eq(arg0))
.
the object to compare against this object for reference dis-equality.
false
if the argument is not a reference to the receiver object; true
otherwise.
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.
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.
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
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; 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
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.
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
the value contained in this Box if it is full; throw an exception otherwise
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
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.
this Box
use productIterator instead
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
the result of the function or a default 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
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
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.
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.
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.
Returns a string representation of the object.
Returns a string representation of the object.
The default representation is platform dependent.
a string representation of the object.
Makes Box play better with Scala 2.
Makes Box play better with Scala 2.8 for comprehensions
Transform an Empty to a ParamFailure with the specified typesafe parameter.
Transform an Empty to a ParamFailure with the specified typesafe parameter.
a value indicating the error
a ParamFailure with the specified value
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:
Full(1).run("zero") { (x: String, y: Int) => y.toString }
Full(1) $ { x: Box[Int] => println(x openOr 0) }