Package com.landawn.abacus.util
Class MutableBoolean
java.lang.Object
com.landawn.abacus.util.MutableBoolean
- All Implemented Interfaces:
Mutable
,Serializable
,Comparable<MutableBoolean>
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.
- Since:
- 2.2
- Version:
- $Id: MutableBoolean.java 1669791 2015-03-28 15:22:59Z britter $
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionint
compareTo
(MutableBoolean other) Compares this mutable to another in ascending order.boolean
Compares this object to the specified object.boolean
Gets the and invert.boolean
getAndSet
(boolean value) Gets the and set.boolean
getValue()
Deprecated.int
hashCode()
Returns a suitable hash code for this mutable.void
invert()
Invert.boolean
Invert and get.boolean
isFalse()
Checks if the current value isfalse
.boolean
isTrue()
Checks if the current value istrue
.static MutableBoolean
of
(boolean value) boolean
setAndGet
(boolean value) Sets the and get.void
setFalse()
Sets the value to true.<E extends Exception>
booleansetIf
(boolean newValue, Throwables.BooleanPredicate<E> predicate) Set with the specified new value and returnstrue
ifpredicate
returns true.void
setTrue()
Sets the value to false.void
setValue
(boolean value) Sets the value.toString()
Returns the String value of this mutable.boolean
value()
-
Method Details
-
of
- Parameters:
value
-- Returns:
-
value
public boolean value()- Returns:
-
getValue
Deprecated.replace byvalue()
.Gets the value as a Boolean instance.- Returns:
-
setValue
public void setValue(boolean value) Sets the value.- Parameters:
value
- the value to set
-
getAndSet
public boolean getAndSet(boolean value) Gets the and set.- Parameters:
value
-- Returns:
-
setAndGet
public boolean setAndGet(boolean value) Sets the and get.- Parameters:
value
-- Returns:
-
getAndInvert
public boolean getAndInvert()Gets the and invert.- Returns:
-
invertAndGet
public boolean invertAndGet()Invert and get.- Returns:
-
setIf
public <E extends Exception> boolean setIf(boolean newValue, Throwables.BooleanPredicate<E> predicate) throws E Set with the specified new value and returnstrue
ifpredicate
returns true. Otherwise just returnfalse
without setting the value to new value.- Type Parameters:
E
-- Parameters:
newValue
-predicate
- - test the current value.- Returns:
- Throws:
E
- the e
-
setFalse
public void setFalse()Sets the value to true.- Since:
- 3.3
-
setTrue
public void setTrue()Sets the value to false.- Since:
- 3.3
-
isTrue
public boolean isTrue()Checks if the current value istrue
.- Returns:
true
if the current value istrue
- Since:
- 2.5
-
isFalse
public boolean isFalse()Checks if the current value isfalse
.- Returns:
true
if the current value isfalse
- Since:
- 2.5
-
invert
public void invert()Invert. -
compareTo
Compares this mutable to another in ascending order.- Specified by:
compareTo
in interfaceComparable<MutableBoolean>
- Parameters:
other
- the other mutable to compare to, not null- Returns:
- negative if this is less, zero if equal, positive if greater where false is less than true
-
equals
Compares this object to the specified object. The result istrue
if and only if the argument is notnull
and is anMutableBoolean
object that contains the sameboolean
value as this object. -
hashCode
public int hashCode()Returns a suitable hash code for this mutable. -
toString
Returns the String value of this mutable.
-
value()
.