Package tech.units.indriya.quantity
Class ByteQuantity<Q extends javax.measure.Quantity<Q>>
java.lang.Object
tech.units.indriya.AbstractQuantity<Q>
tech.units.indriya.quantity.ByteQuantity<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>
An amount of quantity, consisting of a short and a Unit. ByteQuantity objects are immutable.
- Since:
- 1.0.7
- Version:
- 0.1, $Date: 2017-05-28 $
- See Also:
-
AbstractQuantity
Quantity
-
Nested Class Summary
Nested classes/interfaces inherited from class tech.units.indriya.AbstractQuantity
AbstractQuantity.Equalizer
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final long
private final byte
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()
private boolean
isOverflowing
(double value) long
multiply
(javax.measure.Quantity<?> multiplier) 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
private final byte value
-
-
Constructor Details
-
ByteQuantity
ByteQuantity(byte value, javax.measure.Unit<Q> unit)
-
-
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>>
-
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>>
-
decimalValue
- Specified by:
decimalValue
in classAbstractQuantity<Q extends javax.measure.Quantity<Q>>
-
isOverflowing
private boolean isOverflowing(double value) -
addRaw
-
add
- See Also:
-
Quantity.add(Quantity)
-
subtract
- See Also:
-
Quantity.subtract(Quantity)
-
divide
- See Also:
-
Quantity.divide(Quantity)
-
divide
- See Also:
-
Quantity.divide(Number)
-
multiply
- See Also:
-
Quantity.multiply(Quantity)
-
multiply
- See Also:
-
Quantity.multiply(Number)
-
inverse
- See Also:
-
Quantity.inverse()
-
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())
-