Package dev.brachtendorf.mutable
Class MutableDouble
- java.lang.Object
-
- java.lang.Number
-
- dev.brachtendorf.mutable.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 Summary
Constructors Constructor Description MutableDouble()Create a mutable Double with an initial value of 0MutableDouble(double initialValue)Create a mutable Double.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(MutableDouble o)doubledoubleValue()booleanequals(Object obj)floatfloatValue()DoublegetValue()Get an object encapsulating the current valueinthashCode()intintValue()longlongValue()voidsetValue(double newValue)Set the internal field to the new valuevoidsetValue(Double newValue)Set the internal field to the new value-
Methods inherited from class java.lang.Number
byteValue, shortValue
-
-
-
-
Method Detail
-
compareTo
public int compareTo(MutableDouble o)
- Specified by:
compareToin interfaceComparable<MutableDouble>
-
getValue
public Double getValue()
Description copied from interface:MutableGet an object encapsulating the current value
-
setValue
public void setValue(Double newValue)
Description copied from interface:MutableSet the internal field to 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:
doubleValuein classNumber- Returns:
- the current value as double primitive
-
floatValue
public float floatValue()
- Specified by:
floatValuein classNumber
-
-