public final class MutableBoolean extends Object implements Mutable, Serializable, 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.
MutableBoolean is NOT thread-safe.
Boolean,
Serialized Form| Modifier and Type | Method and Description |
|---|---|
int |
compareTo(MutableBoolean other)
Compares this mutable to another in ascending order.
|
boolean |
equals(Object obj)
Compares this object to the specified object.
|
boolean |
getAndInvert()
Gets the and invert.
|
boolean |
getAndSet(boolean value)
Gets the and set.
|
boolean |
getValue()
Deprecated.
replace by
value(). |
int |
hashCode()
Returns a suitable hash code for this mutable.
|
void |
invert()
Invert.
|
boolean |
invertAndGet()
Invert and get.
|
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)
Sets the and get.
|
void |
setFalse()
Sets the value to true.
|
<E extends Exception> |
setIf(boolean newValue,
Throwables.BooleanBiPredicate<E> predicate)
Deprecated.
|
<E extends Exception> |
setIf(boolean newValue,
Throwables.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.
|
String |
toString()
Returns the String value of this mutable.
|
boolean |
value() |
public static MutableBoolean of(boolean value)
value - public boolean value()
@Deprecated public boolean getValue()
value().public void setValue(boolean value)
public boolean getAndSet(boolean value)
value - public boolean setAndGet(boolean value)
value - public boolean getAndInvert()
public boolean invertAndGet()
public <E extends Exception> boolean setIf(boolean newValue, Throwables.BooleanPredicate<E> predicate) throws E extends Exception
true if predicate returns true.
Otherwise just return false without setting the value to new value.E - newValue - predicate - - test the current value.E - the eE extends Exception@Deprecated public <E extends Exception> boolean setIf(boolean newValue, Throwables.BooleanBiPredicate<E> predicate) throws E extends Exception
true if predicate returns true.
Otherwise just return false without setting the value to new value.E - newValue - predicate - the first parameter is the current value, the second parameter is the new value.E - the eE extends Exceptionpublic void setFalse()
public void setTrue()
public boolean isTrue()
true.true if the current value is truepublic boolean isFalse()
false.true if the current value is falsepublic void invert()
public int compareTo(MutableBoolean other)
compareTo in interface Comparable<MutableBoolean>public boolean equals(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.
obj the object to compare with, null returns falsepublic int hashCode()
Copyright © 2021. All rights reserved.