Package tech.units.indriya.quantity
Class DoubleQuantity<Q extends javax.measure.Quantity<Q>>
java.lang.Object
tech.units.indriya.AbstractQuantity<Q>
tech.units.indriya.quantity.DoubleQuantity<Q>
- Type Parameters:
Q
- The type of the quantity.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 DoubleQuantity<Q extends javax.measure.Quantity<Q>>
extends AbstractQuantity<Q>
implements Serializable
An amount of quantity, implementation of
ComparableQuantity
that uses Double
as implementation of Number
, this object is
immutable. Note: all operations which involves Number
, this implementation will convert to Double
.- Since:
- 1.0
- Version:
- 0.4, $Date: 2017-05-28 $
- See Also:
-
AbstractQuantity
Quantity
ComparableQuantity
-
Nested Class Summary
Nested classes/interfaces inherited from class tech.units.indriya.AbstractQuantity
AbstractQuantity.Equalizer
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final long
(package private) final double
Fields inherited from class tech.units.indriya.AbstractQuantity
NONE, ONE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate ComparableQuantity<Q>
decimalValue
(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()
long
multiply
(javax.measure.Quantity<?> 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 Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
value
final double value
-
-
Constructor Details
-
DoubleQuantity
-
-
Method Details
-
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
-
longValue
- Overrides:
longValue
in classAbstractQuantity<Q extends javax.measure.Quantity<Q>>
-
addRaw
-
add
-
subtract
-
multiply
-
multiply
-
divide
-
divide
-
inverse
-
isBig
public boolean isBig()- Specified by:
isBig
in classAbstractQuantity<Q extends javax.measure.Quantity<Q>>
-
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())
-