Package org.apache.commons.lang.mutable
Class MutableBoolean
- java.lang.Object
-
- org.apache.commons.lang.mutable.MutableBoolean
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Comparable,Mutable
public class MutableBoolean extends java.lang.Object implements Mutable, java.io.Serializable, java.lang.Comparable
A mutablebooleanwrapper.- Since:
- 2.2
- See Also:
Boolean, Serialized Form
-
-
Constructor Summary
Constructors Constructor Description MutableBoolean()Constructs a new MutableBoolean with the default value of false.MutableBoolean(boolean value)Constructs a new MutableBoolean with the specified value.MutableBoolean(java.lang.Boolean value)Constructs a new MutableBoolean with the specified value.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanbooleanValue()Returns the value of this MutableBoolean as a boolean.intcompareTo(java.lang.Object obj)Compares this mutable to another in ascending order.booleanequals(java.lang.Object obj)Compares this object to the specified object.java.lang.ObjectgetValue()Gets the value as a Boolean instance.inthashCode()Returns a suitable hash code for this mutable.booleanisFalse()Checks if the current value isfalse.booleanisTrue()Checks if the current value istrue.voidsetValue(boolean value)Sets the value.voidsetValue(java.lang.Object value)Sets the value from any Boolean instance.java.lang.BooleantoBoolean()Gets this mutable as an instance of Boolean.java.lang.StringtoString()Returns the String value of this mutable.
-
-
-
Constructor Detail
-
MutableBoolean
public MutableBoolean()
Constructs a new MutableBoolean with the default value of false.
-
MutableBoolean
public MutableBoolean(boolean value)
Constructs a new MutableBoolean with the specified value.- Parameters:
value- the initial value to store
-
MutableBoolean
public MutableBoolean(java.lang.Boolean value)
Constructs a new MutableBoolean with the specified value.- Parameters:
value- the initial value to store, not null- Throws:
java.lang.NullPointerException- if the object is null
-
-
Method Detail
-
getValue
public java.lang.Object getValue()
Gets the value as a Boolean instance.
-
setValue
public void setValue(boolean value)
Sets the value.- Parameters:
value- the value to set
-
setValue
public void setValue(java.lang.Object value)
Sets the value from any Boolean instance.
-
isTrue
public boolean isTrue()
Checks if the current value istrue.- Returns:
trueif the current value istrue- Since:
- 2.5
-
isFalse
public boolean isFalse()
Checks if the current value isfalse.- Returns:
trueif the current value isfalse- Since:
- 2.5
-
booleanValue
public boolean booleanValue()
Returns the value of this MutableBoolean as a boolean.- Returns:
- the boolean value represented by this object.
-
toBoolean
public java.lang.Boolean toBoolean()
Gets this mutable as an instance of Boolean.- Returns:
- a Boolean instance containing the value from this mutable, never null
- Since:
- 2.5
-
equals
public boolean equals(java.lang.Object obj)
Compares this object to the specified object. The result istrueif and only if the argument is notnulland is anMutableBooleanobject that contains the samebooleanvalue as this object.- Overrides:
equalsin classjava.lang.Object- Parameters:
obj- the object to compare with, null returns false- Returns:
trueif the objects are the same;falseotherwise.
-
hashCode
public int hashCode()
Returns a suitable hash code for this mutable.- Overrides:
hashCodein classjava.lang.Object- Returns:
- the hash code returned by
Boolean.TRUEorBoolean.FALSE
-
compareTo
public int compareTo(java.lang.Object obj)
Compares this mutable to another in ascending order.- Specified by:
compareToin interfacejava.lang.Comparable- Parameters:
obj- 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
-
toString
public java.lang.String toString()
Returns the String value of this mutable.- Overrides:
toStringin classjava.lang.Object- Returns:
- the mutable value as a string
-
-