Package dev.brachtendorf.mutable
Class MutableBoolean
- java.lang.Object
-
- dev.brachtendorf.mutable.MutableBoolean
-
- All Implemented Interfaces:
Mutable<Boolean>,Serializable,Comparable<MutableBoolean>
public class MutableBoolean extends Object implements Mutable<Boolean>, Comparable<MutableBoolean>, Serializable
Mutable class wrapper for boolean values. Mutable classes are useful in lambda expressions or anonymous classes which want to alter the content of a variable but are limited to final or effective final variables. Be aware that the hashcode changes if the value is updated resulting in the object not being retrievable in hash collections.- Since:
- 1.0.0 com.github.kilianB
- Author:
- Kilian
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description MutableBoolean()Create a mutable Boolean with an initial value of FalseMutableBoolean(boolean initialValue)Create a mutable Boolean.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanbooleanValue()intcompareTo(MutableBoolean o)booleanequals(Object obj)BooleangetValue()Get an object encapsulating the current valueinthashCode()voidinvertValue()Invert the value of the internal fieldvoidsetValue(boolean newValue)Set the internal field to the new valuevoidsetValue(Boolean newValue)Set the internal field to the new value
-
-
-
Method Detail
-
getValue
public Boolean getValue()
Description copied from interface:MutableGet an object encapsulating the current value
-
setValue
public void setValue(Boolean newValue)
Description copied from interface:MutableSet the internal field to the new value
-
setValue
public void setValue(boolean newValue)
Set the internal field to the new value- Parameters:
newValue- the new value- Since:
- 1.2.0 com.github.kilianB
-
booleanValue
public boolean booleanValue()
-
invertValue
public void invertValue()
Invert the value of the internal field
-
compareTo
public int compareTo(MutableBoolean o)
- Specified by:
compareToin interfaceComparable<MutableBoolean>
-
-