Class MutableDouble

  • All Implemented Interfaces:
    Mutable<Double>, Serializable, Comparable<MutableDouble>

    public class MutableDouble
    extends Number
    implements Mutable<Double>, Comparable<MutableDouble>
    Mutable class wrapper for double 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

      • MutableDouble

        public MutableDouble()
        Create a mutable Double with an initial value of 0
      • MutableDouble

        public MutableDouble​(double initialValue)
        Create a mutable Double.
        Parameters:
        initialValue - the initial value of the float
    • Method Detail

      • getValue

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

        public void setValue​(Double newValue)
        Description copied from interface: Mutable
        Set the internal field to the new value
        Specified by:
        setValue in interface Mutable<Double>
        Parameters:
        newValue - the new value
      • setValue

        public void setValue​(double newValue)
        Set the internal field to the new value
        Parameters:
        newValue - the new value
        Since:
        1.2.0 com.github.kilianB
      • doubleValue

        public double doubleValue()
        Specified by:
        doubleValue in class Number
        Returns:
        the current value as double primitive
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • intValue

        public int intValue()
        Specified by:
        intValue in class Number
      • longValue

        public long longValue()
        Specified by:
        longValue in class Number
      • floatValue

        public float floatValue()
        Specified by:
        floatValue in class Number