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:
Serializable
,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<Number>
final class BigIntegerQuantity<Q extends javax.measure.Quantity<Q>>
extends AbstractQuantity<Q>
implements Serializable
An amount of quantity, implementation of
ComparableQuantity
that uses BigInteger
as implementation of Number
, this object
is immutable. Note: all operations which involves Number
, this implementation will convert to BigInteger
.- 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
FieldsFields inherited from class tech.units.indriya.AbstractQuantity
NONE, ONE
-
Constructor Summary
ConstructorsConstructorDescriptionBigIntegerQuantity
(long value, javax.measure.Unit<Q> unit) BigIntegerQuantity
(BigInteger value, javax.measure.Unit<Q> unit) -
Method Summary
Modifier and TypeMethodDescriptiondecimalValue
(javax.measure.Unit<Q> unit) divide
(javax.measure.Quantity<?> that) double
doubleValue
(javax.measure.Unit<Q> unit) boolean
Compares this quantity against the specified object for strict equality (same unit and same amount).getValue()
Returns the numeric value of the quantity.inverse()
boolean
isBig()
protected long
multiply
(javax.measure.Quantity<?> that) negate()
Not-API (not yet)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 Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
value
-
-
Constructor Details
-
BigIntegerQuantity
-
BigIntegerQuantity
-
-
Method Details
-
negate
Not-API (not yet)Returns a BigIntegerQuantity with same Unit, but whose value is (-this.getValue()).
- Returns:
-
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
- Specified by:
doubleValue
in classAbstractQuantity<Q extends javax.measure.Quantity<Q>>
-
decimalValue
- Specified by:
decimalValue
in classAbstractQuantity<Q extends javax.measure.Quantity<Q>>
- Throws:
ArithmeticException
-
add
-
subtract
-
multiply
-
multiply
-
divide
-
inverse
-
longValue
- 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
-
equals
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())
-