Package com.helger.base.numeric.mutable
Class MutableLong
java.lang.Object
java.lang.Number
com.helger.base.numeric.mutable.AbstractMutableNumeric<MutableLong>
com.helger.base.numeric.mutable.AbstractMutableInteger<MutableLong>
com.helger.base.numeric.mutable.MutableLong
- All Implemented Interfaces:
ICloneable<MutableLong>,IComparable<MutableLong>,INumber,IMutableInteger<MutableLong>,IMutableNumeric<MutableLong>,IMutableObject<MutableLong>,IGenericImplTrait<MutableLong>,Serializable,Comparable<MutableLong>
Object wrapper around a long so that it can be passed a final object but is
mutable.
- Author:
- Philip Helger
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionMutableLong(long nValue) Initialize with a certain value.MutableLong(@NonNull Number aValue) Initialize with a certain value. -
Method Summary
Modifier and TypeMethodDescriptionintcompareTo(@NonNull MutableLong rhs) longdec()Decrement by 1 and return the modified value.longdec(long nDelta) Decrement by the given delta and return the modified value.longDecrement by the given delta and return the modified value.longdivide(long nDivisor) Divide the current value by the given divisor.longDivide the current value by the given divisor.doubleReturns the value of the specified number as adouble, which may involve rounding.booleanfloatReturns the value of the specified number as afloat, which may involve rounding.longGet the current value and then increment by 1.@NonNull MutableLonggetClone()inthashCode()longinc()Increment by 1 and return the modified value.longinc(long nDelta) Increment by the given delta and return the modified value.longIncrement by the given delta and return the modified value.longIncrement by 1 and then get the new value.intintValue()Returns the value of the specified number as anint, which may involve rounding or truncation.booleanis0()booleanisEven()booleanisGE0()booleanisGT0()booleanisLE0()booleanisLT0()longReturns the value of the specified number as along, which may involve rounding or truncation.longmultiply(long nMultiplicand) Multiply the current value by the given multiplicand.longMultiply the current value by the given multiplicand.@NonNull EChangeset(long nValue) Set a new value.@NonNull EChangeSet a new value.toString()Methods inherited from class com.helger.base.numeric.mutable.AbstractMutableNumeric
onAfterChangeMethods inherited from class java.lang.Number
byteValue, shortValueMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.helger.base.compare.IComparable
isEQ, isGE, isGT, isLE, isLT, isNEMethods inherited from interface com.helger.base.trait.IGenericImplTrait
thisAsTMethods inherited from interface com.helger.base.numeric.mutable.IMutableInteger
isOddMethods inherited from interface com.helger.base.numeric.mutable.IMutableNumeric
getAsBigDecimal, getAsBigInteger, getAsByte, getAsCharacter, getAsDouble, getAsFloat, getAsInteger, getAsLong, getAsShort, isNot0Methods inherited from interface com.helger.base.numeric.INumber
byteValue, shortValue
-
Constructor Details
-
MutableLong
Initialize with a certain value.- Parameters:
aValue- The value to be used.
-
MutableLong
public MutableLong(long nValue) Initialize with a certain value.- Parameters:
nValue- The value to be used.
-
-
Method Details
-
longValue
public long longValue()Description copied from interface:INumberReturns the value of the specified number as along, which may involve rounding or truncation. -
floatValue
public float floatValue()Description copied from interface:INumberReturns the value of the specified number as afloat, which may involve rounding.- Specified by:
floatValuein interfaceINumber- Specified by:
floatValuein classNumber- Returns:
- the numeric value represented by this object after conversion to
type
float.
-
doubleValue
public double doubleValue()Description copied from interface:INumberReturns the value of the specified number as adouble, which may involve rounding.- Specified by:
doubleValuein interfaceINumber- Specified by:
doubleValuein classNumber- Returns:
- the numeric value represented by this object after conversion to
type
double.
-
intValue
public int intValue()Description copied from interface:INumberReturns the value of the specified number as anint, which may involve rounding or truncation. -
inc
public long inc()Increment by 1 and return the modified value.- Returns:
- The by 1 incremented value.
-
inc
public long inc(long nDelta) Increment by the given delta and return the modified value.- Parameters:
nDelta- The delta to add.- Returns:
- The new value after incrementing.
-
inc
Increment by the given delta and return the modified value.- Parameters:
aDelta- The delta to add. May not benull.- Returns:
- The new value after incrementing.
-
dec
public long dec()Decrement by 1 and return the modified value.- Returns:
- The by 1 decremented value.
-
dec
public long dec(long nDelta) Decrement by the given delta and return the modified value.- Parameters:
nDelta- The delta to subtract.- Returns:
- The new value after decrementing.
-
dec
Decrement by the given delta and return the modified value.- Parameters:
aDelta- The delta to subtract. May not benull.- Returns:
- The new value after decrementing.
-
divide
public long divide(long nDivisor) Divide the current value by the given divisor.- Parameters:
nDivisor- The divisor to use.- Returns:
- The new value after division.
-
divide
Divide the current value by the given divisor.- Parameters:
aDivisor- The divisor to use. May not benull.- Returns:
- The new value after division.
-
multiply
public long multiply(long nMultiplicand) Multiply the current value by the given multiplicand.- Parameters:
nMultiplicand- The multiplicand to use.- Returns:
- The new value after multiplication.
-
multiply
Multiply the current value by the given multiplicand.- Parameters:
aMultiplicand- The multiplicand to use. May not benull.- Returns:
- The new value after multiplication.
-
set
Set a new value.- Parameters:
nValue- The new value to set.- Returns:
EChange.CHANGEDif the value was changed.
-
set
Set a new value.- Parameters:
aValue- The new value to set. May not benull.- Returns:
EChange.CHANGEDif the value was changed.
-
is0
public boolean is0()- Returns:
trueif the value is 0
-
isLT0
public boolean isLT0()- Returns:
trueif the value is < 0
-
isLE0
public boolean isLE0()- Returns:
trueif the value is ≤ 0
-
isGT0
public boolean isGT0()- Returns:
trueif the value is > 0
-
isGE0
public boolean isGE0()- Returns:
trueif the value is ≥ 0
-
isEven
public boolean isEven()- Returns:
trueif the value is even
-
getAndInc
public long getAndInc()Get the current value and then increment by 1.- Returns:
- The value before incrementing.
-
incAndGet
public long incAndGet()Increment by 1 and then get the new value.- Returns:
- The value after incrementing.
-
compareTo
-
getClone
- Returns:
- A 100% deep-copy of the implementing class.
-
equals
-
hashCode
public int hashCode() -
toString
-