Package tech.units.indriya.quantity
Class BigIntegerQuantity<Q extends javax.measure.Quantity<Q>>
- java.lang.Object
-
- tech.units.indriya.AbstractQuantity<Q>
-
- tech.units.indriya.quantity.BigIntegerQuantity<Q>
-
- Type Parameters:
Q
- The type of the quantity.
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<javax.measure.Quantity<Q>>
,javax.measure.Quantity<Q>
,ComparableQuantity<Q>
,tech.uom.lib.common.function.QuantityConverter<Q>
,tech.uom.lib.common.function.UnitSupplier<Q>
,tech.uom.lib.common.function.ValueSupplier<java.lang.Number>
final class BigIntegerQuantity<Q extends javax.measure.Quantity<Q>> extends AbstractQuantity<Q> implements java.io.Serializable
An amount of quantity, implementation ofComparableQuantity
that usesBigInteger
as implementation ofNumber
, this object is immutable. Note: all operations which involvesNumber
, this implementation will convert toBigInteger
.- Since:
- 2.0
- Version:
- 0.3
- See Also:
AbstractQuantity
,Quantity
,ComparableQuantity
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class tech.units.indriya.AbstractQuantity
AbstractQuantity.Equalizer
-
-
Field Summary
Fields Modifier and Type Field Description private static long
serialVersionUID
private java.math.BigInteger
value
-
Fields inherited from class tech.units.indriya.AbstractQuantity
NONE, ONE
-
-
Constructor Summary
Constructors Constructor Description BigIntegerQuantity(long value, javax.measure.Unit<Q> unit)
BigIntegerQuantity(java.math.BigInteger value, javax.measure.Unit<Q> unit)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ComparableQuantity<Q>
add(javax.measure.Quantity<Q> that)
java.math.BigDecimal
decimalValue(javax.measure.Unit<Q> unit)
ComparableQuantity<Q>
divide(java.lang.Number that)
ComparableQuantity<?>
divide(javax.measure.Quantity<?> that)
double
doubleValue(javax.measure.Unit<Q> unit)
boolean
equals(java.lang.Object obj)
Compares this quantity against the specified object for strict equality (same unit and same amount).java.math.BigInteger
getValue()
Returns the numeric value of the quantity.ComparableQuantity<Q>
inverse()
boolean
isBig()
protected long
longValue(javax.measure.Unit<Q> unit)
ComparableQuantity<Q>
multiply(java.lang.Number that)
ComparableQuantity<?>
multiply(javax.measure.Quantity<?> that)
BigIntegerQuantity
negate()
Not-API (not yet)ComparableQuantity<Q>
subtract(javax.measure.Quantity<Q> that)
-
Methods inherited from class tech.units.indriya.AbstractQuantity
asType, compareTo, divide, equals, floatValue, getUnit, hasFraction, hasFraction, hashCode, intValue, inverse, isEquivalentOf, isGreaterThan, isGreaterThanOrEqualTo, isLessThan, isLessThanOrEqualTo, multiply, parse, to, toString
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
value
private final java.math.BigInteger value
-
-
Method Detail
-
negate
public BigIntegerQuantity negate()
Not-API (not yet)Returns a BigIntegerQuantity with same Unit, but whose value is (-this.getValue()).
- Returns:
-
getValue
public java.math.BigInteger getValue()
Description copied from class:AbstractQuantity
Returns the numeric value of the quantity.- Specified by:
getValue
in interfacejavax.measure.Quantity<Q extends javax.measure.Quantity<Q>>
- Specified by:
getValue
in interfacetech.uom.lib.common.function.ValueSupplier<Q extends javax.measure.Quantity<Q>>
- Specified by:
getValue
in classAbstractQuantity<Q extends javax.measure.Quantity<Q>>
- Returns:
- the quantity value.
-
doubleValue
public double doubleValue(javax.measure.Unit<Q> unit)
- Specified by:
doubleValue
in classAbstractQuantity<Q extends javax.measure.Quantity<Q>>
-
decimalValue
public java.math.BigDecimal decimalValue(javax.measure.Unit<Q> unit) throws java.lang.ArithmeticException
- Specified by:
decimalValue
in classAbstractQuantity<Q extends javax.measure.Quantity<Q>>
- Throws:
java.lang.ArithmeticException
-
add
public ComparableQuantity<Q> add(javax.measure.Quantity<Q> that)
-
subtract
public ComparableQuantity<Q> subtract(javax.measure.Quantity<Q> that)
-
multiply
public ComparableQuantity<?> multiply(javax.measure.Quantity<?> that)
-
multiply
public ComparableQuantity<Q> multiply(java.lang.Number that)
-
divide
public ComparableQuantity<Q> divide(java.lang.Number that)
-
inverse
public ComparableQuantity<Q> inverse()
-
longValue
protected long longValue(javax.measure.Unit<Q> unit)
- Overrides:
longValue
in classAbstractQuantity<Q extends javax.measure.Quantity<Q>>
-
isBig
public boolean isBig()
- Specified by:
isBig
in classAbstractQuantity<Q extends javax.measure.Quantity<Q>>
-
divide
public ComparableQuantity<?> divide(javax.measure.Quantity<?> that)
-
equals
public boolean equals(java.lang.Object obj)
Description copied from class:AbstractQuantity
Compares this quantity against the specified object for strict equality (same unit and same amount).Similarly to the
BigDecimal.equals(java.lang.Object)
method which consider 2.0 and 2.00 as different objects because of different internal scales, quantities such asQuantities.getQuantity(3.0, KILOGRAM)
Quantities.getQuantity(3, KILOGRAM)
andQuantities.getQuantity("3 kg")
might not be considered equals because of possible differences in their implementations.To compare quantities stated using different units or using different amount implementations the
compareTo
orequals(Quantity, epsilon, epsilonUnit)
methods should be used.- Overrides:
equals
in classAbstractQuantity<Q extends javax.measure.Quantity<Q>>
- Parameters:
obj
- the object to compare with.- Returns:
this.getUnit.equals(obj.getUnit()) && this.getValue().equals(obj.getValue())
-
-