Class 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 Detail

      • MutableBoolean

        public MutableBoolean()
        Create a mutable Boolean with an initial value of False
      • MutableBoolean

        public MutableBoolean​(boolean initialValue)
        Create a mutable Boolean.
        Parameters:
        initialValue - the initial value of the integer
    • Method Detail

      • getValue

        public Boolean getValue()
        Description copied from interface: Mutable
        Get an object encapsulating the current value
        Specified by:
        getValue in interface Mutable<Boolean>
        Returns:
        The current value as an immutable base object
      • setValue

        public void setValue​(Boolean newValue)
        Description copied from interface: Mutable
        Set the internal field to the new value
        Specified by:
        setValue in interface Mutable<Boolean>
        Parameters:
        newValue - 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
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object