public final class MutableBoolean extends java.lang.Object implements Mutable, java.io.Serializable, java.lang.Comparable<MutableBoolean>
Note: it's copied from Apache Commons Lang developed at The Apache Software Foundation (http://www.apache.org/), or under the Apache License 2.0. The methods copied from other products/frameworks may be modified in this class.
A mutableboolean
wrapper.
Note that as MutableBoolean does not extend Boolean, it is not treated by String.format as a Boolean parameter.
Boolean
,
Serialized FormModifier and Type | Method and Description |
---|---|
int |
compareTo(MutableBoolean other)
Compares this mutable to another in ascending order.
|
boolean |
equals(java.lang.Object obj)
Compares this object to the specified object.
|
boolean |
getAndInvert() |
boolean |
getAndSet(boolean value) |
boolean |
getValue()
Deprecated.
replace by
value() . |
int |
hashCode()
Returns a suitable hash code for this mutable.
|
void |
invert() |
boolean |
invertAndGet() |
boolean |
isFalse()
Checks if the current value is
false . |
boolean |
isTrue()
Checks if the current value is
true . |
static MutableBoolean |
of(boolean value) |
boolean |
setAndGet(boolean value) |
void |
setFalse()
Sets the value to true.
|
<E extends java.lang.Exception> |
setIf(boolean newValue,
Try.BooleanBiPredicate<E> predicate)
Set with the specified new value and returns
true if predicate returns true. |
<E extends java.lang.Exception> |
setIf(boolean newValue,
Try.BooleanPredicate<E> predicate)
Set with the specified new value and returns
true if predicate returns true. |
void |
setTrue()
Sets the value to false.
|
void |
setValue(boolean value)
Sets the value.
|
java.lang.String |
toString()
Returns the String value of this mutable.
|
boolean |
value() |
public static MutableBoolean of(boolean value)
public boolean value()
@Deprecated public boolean getValue()
value()
.public void setValue(boolean value)
value
- the value to setpublic boolean getAndSet(boolean value)
public boolean setAndGet(boolean value)
public boolean getAndInvert()
public boolean invertAndGet()
public <E extends java.lang.Exception> boolean setIf(boolean newValue, Try.BooleanPredicate<E> predicate) throws E extends java.lang.Exception
true
if predicate
returns true.
Otherwise just return false
without setting the value to new value.newValue
- predicate
- - test the current value.E extends java.lang.Exception
public <E extends java.lang.Exception> boolean setIf(boolean newValue, Try.BooleanBiPredicate<E> predicate) throws E extends java.lang.Exception
true
if predicate
returns true.
Otherwise just return false
without setting the value to new value.newValue
- predicate
- the first parameter is the current value, the second parameter is the new value.E extends java.lang.Exception
public void setFalse()
public void setTrue()
public boolean isTrue()
true
.true
if the current value is true
public boolean isFalse()
false
.true
if the current value is false
public void invert()
public int compareTo(MutableBoolean other)
compareTo
in interface java.lang.Comparable<MutableBoolean>
other
- the other mutable to compare to, not nullpublic boolean equals(java.lang.Object obj)
true
if and only if the argument is
not null
and is an MutableBoolean
object that contains the same
boolean
value as this object.equals
in class java.lang.Object
obj
- the object to compare with, null returns falsetrue
if the objects are the same; false
otherwise.public int hashCode()
hashCode
in class java.lang.Object
Boolean.TRUE
or Boolean.FALSE
public java.lang.String toString()
toString
in class java.lang.Object