Class MutableBigInteger

All Implemented Interfaces:
ICloneable<MutableBigInteger>, IComparable<MutableBigInteger>, INumber, IMutableNumeric<MutableBigInteger>, IMutableObject<MutableBigInteger>, IGenericImplTrait<MutableBigInteger>, Serializable, Comparable<MutableBigInteger>

@NotThreadSafe public class MutableBigInteger extends AbstractMutableNumeric<MutableBigInteger>
Object wrapper around a BigInteger so that it can be passed a final object but is mutable.
Author:
Philip Helger
See Also:
  • Constructor Details

    • MutableBigInteger

      public MutableBigInteger(long nValue)
      Initialize with a certain long value.
      Parameters:
      nValue - The value to be used.
    • MutableBigInteger

      public MutableBigInteger(@NonNull MutableBigInteger aOther)
      Copy constructor.
      Parameters:
      aOther - The object to copy from. May not be null.
    • MutableBigInteger

      public MutableBigInteger(@NonNull BigInteger aValue)
      Initialize with a certain BigInteger value.
      Parameters:
      aValue - The value to be used. May not be null.
  • Method Details

    • getAsBigDecimal

      public @NonNull BigDecimal getAsBigDecimal()
    • getAsBigInteger

      public @NonNull BigInteger getAsBigInteger()
    • doubleValue

      public double doubleValue()
      Description copied from interface: INumber
      Returns the value of the specified number as a double, which may involve rounding.
      Specified by:
      doubleValue in interface INumber
      Specified by:
      doubleValue in class Number
      Returns:
      the numeric value represented by this object after conversion to type double.
    • floatValue

      public float floatValue()
      Description copied from interface: INumber
      Returns the value of the specified number as a float, which may involve rounding.
      Specified by:
      floatValue in interface INumber
      Specified by:
      floatValue in class Number
      Returns:
      the numeric value represented by this object after conversion to type float.
    • intValue

      public int intValue()
      Description copied from interface: INumber
      Returns the value of the specified number as an int, which may involve rounding or truncation.
      Specified by:
      intValue in interface INumber
      Specified by:
      intValue in class Number
      Returns:
      the numeric value represented by this object after conversion to type int.
    • longValue

      public long longValue()
      Description copied from interface: INumber
      Returns the value of the specified number as a long, which may involve rounding or truncation.
      Specified by:
      longValue in interface INumber
      Specified by:
      longValue in class Number
      Returns:
      the numeric value represented by this object after conversion to type long.
    • inc

      public @NonNull BigInteger inc()
      Increment by 1 and return the modified value.
      Returns:
      The by 1 incremented value.
    • inc

      public @NonNull BigInteger 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. Never null.
    • inc

      public @NonNull BigInteger inc(@NonNull MutableBigInteger aDelta)
      Increment by the given delta and return the modified value.
      Parameters:
      aDelta - The delta to add. May not be null.
      Returns:
      The new value after incrementing. Never null.
    • inc

      public @NonNull BigInteger inc(@NonNull BigInteger aDelta)
      Increment by the given delta and return the modified value.
      Parameters:
      aDelta - The delta to add. May not be null.
      Returns:
      The new value after incrementing. Never null.
    • dec

      public @NonNull BigInteger dec()
      Decrement by 1 and return the modified value.
      Returns:
      The by 1 decremented value. Never null.
    • dec

      public @NonNull BigInteger 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. Never null.
    • dec

      public @NonNull BigInteger dec(@NonNull MutableBigInteger aDelta)
      Decrement by the given delta and return the modified value.
      Parameters:
      aDelta - The delta to subtract. May not be null.
      Returns:
      The new value after decrementing. Never null.
    • dec

      public @NonNull BigInteger dec(@NonNull BigInteger aDelta)
      Decrement by the given delta and return the modified value.
      Parameters:
      aDelta - The delta to subtract. May not be null.
      Returns:
      The new value after decrementing. Never null.
    • divide

      public @NonNull BigInteger divide(long nDivisor)
      Divide the current value by the given divisor.
      Parameters:
      nDivisor - The divisor to use.
      Returns:
      The new value after division. Never null.
    • divide

      public @NonNull BigInteger divide(@NonNull MutableBigInteger aDivisor)
      Divide the current value by the given divisor.
      Parameters:
      aDivisor - The divisor to use. May not be null.
      Returns:
      The new value after division. Never null.
    • divide

      public @NonNull BigInteger divide(@NonNull BigInteger aDivisor)
      Divide the current value by the given divisor.
      Parameters:
      aDivisor - The divisor to use. May not be null.
      Returns:
      The new value after division. Never null.
    • multiply

      public @NonNull BigInteger multiply(long nMultiplicand)
      Multiply the current value by the given multiplicand.
      Parameters:
      nMultiplicand - The multiplicand to use.
      Returns:
      The new value after multiplication. Never null.
    • multiply

      public @NonNull BigInteger multiply(@NonNull MutableBigInteger aMultiplicand)
      Multiply the current value by the given multiplicand.
      Parameters:
      aMultiplicand - The multiplicand to use. May not be null.
      Returns:
      The new value after multiplication. Never null.
    • multiply

      public @NonNull BigInteger multiply(@NonNull BigInteger aMultiplicand)
      Multiply the current value by the given multiplicand.
      Parameters:
      aMultiplicand - The multiplicand to use. May not be null.
      Returns:
      The new value after multiplication. Never null.
    • set

      public @NonNull EChange set(long nDelta)
      Set a new value.
      Parameters:
      nDelta - The new value to set.
      Returns:
      EChange.CHANGED if the value was changed.
    • set

      public @NonNull EChange set(@NonNull MutableBigInteger aValue)
      Set a new value.
      Parameters:
      aValue - The new value to set. May not be null.
      Returns:
      EChange.CHANGED if the value was changed.
    • set

      public @NonNull EChange set(@NonNull BigInteger aValue)
      Set a new value.
      Parameters:
      aValue - The new value to set. May not be null.
      Returns:
      EChange.CHANGED if the value was changed.
    • is0

      public boolean is0()
      Returns:
      true if the value is 0
    • isLT0

      public boolean isLT0()
      Returns:
      true if the value is < 0
    • isLE0

      public boolean isLE0()
      Returns:
      true if the value is ≤ 0
    • isGT0

      public boolean isGT0()
      Returns:
      true if the value is > 0
    • isGE0

      public boolean isGE0()
      Returns:
      true if the value is ≥ 0
    • getAndInc

      public @NonNull BigInteger getAndInc()
      Get the current value and then increment by 1.
      Returns:
      The value before incrementing. Never null.
    • incAndGet

      public @NonNull BigInteger incAndGet()
      Increment by 1 and then get the new value.
      Returns:
      The value after incrementing. Never null.
    • compareTo

      public int compareTo(@NonNull MutableBigInteger rhs)
    • getClone

      public @NonNull MutableBigInteger getClone()
      Returns:
      A 100% deep-copy of the implementing class.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

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

      public String toString()
      Overrides:
      toString in class Object