Package tech.units.indriya.quantity.time
Class TimeUnitQuantity
- java.lang.Object
-
- tech.units.indriya.AbstractQuantity<javax.measure.quantity.Time>
-
- tech.units.indriya.quantity.time.TimeUnitQuantity
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Comparable<javax.measure.Quantity<javax.measure.quantity.Time>>,javax.measure.Quantity<javax.measure.quantity.Time>,ComparableQuantity<javax.measure.quantity.Time>,tech.uom.lib.common.function.QuantityConverter<javax.measure.quantity.Time>,tech.uom.lib.common.function.UnitSupplier<javax.measure.quantity.Time>,tech.uom.lib.common.function.ValueSupplier<java.lang.Number>
public final class TimeUnitQuantity extends AbstractQuantity<javax.measure.quantity.Time>
Class that representsTimeUnitin Unit-API- Since:
- 1.0
- Version:
- 1.0.1
- See Also:
- Serialized Form
-
-
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 longserialVersionUIDprivate java.util.concurrent.TimeUnittimeUnitprivate java.lang.Integervalue-
Fields inherited from class tech.units.indriya.AbstractQuantity
NONE, ONE
-
-
Constructor Summary
Constructors Constructor Description TimeUnitQuantity(java.util.concurrent.TimeUnit timeUnit, java.lang.Integer value)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description ComparableQuantity<javax.measure.quantity.Time>add(javax.measure.Quantity<javax.measure.quantity.Time> that)java.math.BigDecimaldecimalValue(javax.measure.Unit<javax.measure.quantity.Time> unit)ComparableQuantity<javax.measure.quantity.Time>divide(java.lang.Number that)ComparableQuantity<?>divide(javax.measure.Quantity<?> that)doubledoubleValue(javax.measure.Unit<javax.measure.quantity.Time> unit)booleanequals(java.lang.Object obj)Compares this quantity against the specified object for strict equality (same unit and same amount).java.util.concurrent.TimeUnitgetTimeUnit()get toTimeUnitjava.lang.IntegergetValue()get value expressed inIntegerinthashCode()Returns the hash code for this quantity.ComparableQuantity<javax.measure.quantity.Frequency>inverse()booleanisBig()ComparableQuantity<javax.measure.quantity.Time>multiply(java.lang.Number multiplier)ComparableQuantity<?>multiply(javax.measure.Quantity<?> multiplier)static TimeUnitQuantityof(java.lang.Integer number, java.util.concurrent.TimeUnit timeUnit)static TimeUnitQuantityof(java.util.concurrent.TimeUnit timeUnit, java.lang.Integer number)Deprecated.use #of(Integer, TimeUnit)static TimeUnitQuantityof(javax.measure.Quantity<javax.measure.quantity.Time> quantity)ComparableQuantity<javax.measure.quantity.Time>subtract(javax.measure.Quantity<javax.measure.quantity.Time> that)TimeUnitQuantityto(java.util.concurrent.TimeUnit timeUnit)javax.measure.Quantity<javax.measure.quantity.Time>toQuantity()Converts theTimeUnitQuantitytoQuantityjava.lang.StringtoString()Returns theStringrepresentation of this quantity.javax.measure.Unit<javax.measure.quantity.Time>toUnit()converts theTimeUnittoUnitprivate static javax.measure.Unit<javax.measure.quantity.Time>toUnit(java.util.concurrent.TimeUnit timeUnit)-
Methods inherited from class tech.units.indriya.AbstractQuantity
asType, compareTo, divide, equals, floatValue, getUnit, hasFraction, hasFraction, intValue, inverse, isEquivalentOf, isGreaterThan, isGreaterThanOrEqualTo, isLessThan, isLessThanOrEqualTo, longValue, multiply, parse, to
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
timeUnit
private final java.util.concurrent.TimeUnit timeUnit
-
value
private final java.lang.Integer value
-
-
Method Detail
-
of
public static TimeUnitQuantity of(java.lang.Integer number, java.util.concurrent.TimeUnit timeUnit)
- Parameters:
timeUnit- - time to be usedvalue- - value to be used- Since:
- 1.0.9
-
of
public static TimeUnitQuantity of(java.util.concurrent.TimeUnit timeUnit, java.lang.Integer number)
Deprecated.use #of(Integer, TimeUnit)- Parameters:
timeUnit- - time to be usedvalue- - value to be used- Since:
- 1.0
-
of
public static TimeUnitQuantity of(javax.measure.Quantity<javax.measure.quantity.Time> quantity)
- Parameters:
quantity- - quantity to be used- Returns:
- the
TimeUnitQuantityconverted be quantity in seconds. - Since:
- 1.0
-
getTimeUnit
public java.util.concurrent.TimeUnit getTimeUnit()
get toTimeUnit- Returns:
- the TimeUnit
- Since:
- 1.0
-
getValue
public java.lang.Integer getValue()
get value expressed inInteger- Specified by:
getValuein interfacejavax.measure.Quantity<javax.measure.quantity.Time>- Specified by:
getValuein interfacetech.uom.lib.common.function.ValueSupplier<java.lang.Number>- Specified by:
getValuein classAbstractQuantity<javax.measure.quantity.Time>- Returns:
- the value
- Since:
- 1.0
-
toUnit
public javax.measure.Unit<javax.measure.quantity.Time> toUnit()
converts theTimeUnittoUnit- Returns:
- the
getTimeUnit()converted to Unit - Since:
- 1.0
-
toQuantity
public javax.measure.Quantity<javax.measure.quantity.Time> toQuantity()
Converts theTimeUnitQuantitytoQuantity- Returns:
- this class converted to Quantity
- Since:
- 1.0
-
to
public TimeUnitQuantity to(java.util.concurrent.TimeUnit timeUnit)
-
toUnit
private static javax.measure.Unit<javax.measure.quantity.Time> toUnit(java.util.concurrent.TimeUnit timeUnit)
-
hashCode
public int hashCode()
Description copied from class:AbstractQuantityReturns the hash code for this quantity.- Overrides:
hashCodein classAbstractQuantity<javax.measure.quantity.Time>- Returns:
- the hash code value.
- Since:
- 1.0
-
equals
public boolean equals(java.lang.Object obj)
Description copied from class:AbstractQuantityCompares 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
compareToorequals(Quantity, epsilon, epsilonUnit)methods should be used.- Overrides:
equalsin classAbstractQuantity<javax.measure.quantity.Time>- Parameters:
obj- the object to compare with.- Returns:
this.getUnit.equals(obj.getUnit()) && this.getValue().equals(obj.getValue())- Since:
- 1.0
-
toString
public java.lang.String toString()
Description copied from class:AbstractQuantityReturns theStringrepresentation of this quantity. The string produced for a given quantity is always the same; it is not affected by locale. This means that it can be used as a canonical string representation for exchanging quantity, or as a key for a Hashtable, etc. Locale-sensitive quantity formatting and parsing is handled by theQuantityFormatimplementations and its subclasses.- Overrides:
toStringin classAbstractQuantity<javax.measure.quantity.Time>- Returns:
UnitFormat.getInternational().format(this)
-
add
public ComparableQuantity<javax.measure.quantity.Time> add(javax.measure.Quantity<javax.measure.quantity.Time> that)
- Since:
- 1.0.1
- See Also:
Quantity.add(Quantity)
-
subtract
public ComparableQuantity<javax.measure.quantity.Time> subtract(javax.measure.Quantity<javax.measure.quantity.Time> that)
- Since:
- 1.0.1
- See Also:
Quantity.subtract(Quantity)
-
divide
public ComparableQuantity<?> divide(javax.measure.Quantity<?> that)
- Since:
- 1.0.1
- See Also:
Quantity.divide(Quantity)
-
divide
public ComparableQuantity<javax.measure.quantity.Time> divide(java.lang.Number that)
- Since:
- 1.0.1
- See Also:
Quantity.divide(Number)
-
multiply
public ComparableQuantity<?> multiply(javax.measure.Quantity<?> multiplier)
- Since:
- 1.0.1
- See Also:
Quantity.multiply(Quantity)
-
multiply
public ComparableQuantity<javax.measure.quantity.Time> multiply(java.lang.Number multiplier)
- Since:
- 1.0.1
- See Also:
Quantity.multiply(Number)
-
inverse
public ComparableQuantity<javax.measure.quantity.Frequency> inverse()
- Since:
- 1.0.1
- See Also:
Quantity.inverse()
-
isBig
public boolean isBig()
- Specified by:
isBigin classAbstractQuantity<javax.measure.quantity.Time>- Since:
- 1.0.1
-
decimalValue
public java.math.BigDecimal decimalValue(javax.measure.Unit<javax.measure.quantity.Time> unit) throws java.lang.ArithmeticException- Specified by:
decimalValuein classAbstractQuantity<javax.measure.quantity.Time>- Throws:
java.lang.ArithmeticException- Since:
- 1.0.1
-
doubleValue
public double doubleValue(javax.measure.Unit<javax.measure.quantity.Time> unit) throws java.lang.ArithmeticException- Specified by:
doubleValuein classAbstractQuantity<javax.measure.quantity.Time>- Throws:
java.lang.ArithmeticException- Since:
- 1.0.1
-
-