Class TimeUnitQuantity

  • All Implemented Interfaces:
    Serializable, 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<Number>

    public final class TimeUnitQuantity
    extends AbstractQuantity<javax.measure.quantity.Time>
    Class that represents TimeUnit in Unit-API
    Since:
    1.0
    Version:
    1.0.5
    Author:
    otaviojava, keilw, Andi Huber
    See Also:
    Serialized Form
    • Method Detail

      • of

        public static TimeUnitQuantity of​(javax.measure.Quantity<javax.measure.quantity.Time> quantity)
        Creates a TimeUnitQuantity based a Quantity converted to SI#SECOND.
        Parameters:
        quantity - - quantity to be used
        Returns:
        the TimeUnitQuantity converted be quantity in seconds.
        Since:
        1.0
      • getValue

        public Number getValue()
        get value expressed in Number
        Specified by:
        getValue in interface javax.measure.Quantity<javax.measure.quantity.Time>
        Specified by:
        getValue in interface tech.uom.lib.common.function.ValueSupplier<Number>
        Specified by:
        getValue in class AbstractQuantity<javax.measure.quantity.Time>
        Returns:
        the value
        Since:
        1.0
      • toUnit

        public javax.measure.Unit<javax.measure.quantity.Time> toUnit()
        converts the TimeUnit to Unit
        Returns:
        the getTimeUnit() converted to Unit
        Since:
        1.0
      • toQuantity

        public javax.measure.Quantity<javax.measure.quantity.Time> toQuantity()
        Converts the TimeUnitQuantity to Quantity
        Returns:
        this class converted to Quantity
        Since:
        1.0
      • hashCode

        public int hashCode()
        Description copied from class: AbstractQuantity
        Returns the hash code for this quantity.
        Overrides:
        hashCode in class AbstractQuantity<javax.measure.quantity.Time>
        Returns:
        the hash code value.
        Since:
        1.0
      • equals

        public boolean equals​(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 as Quantities.getQuantity(3.0, KILOGRAM) Quantities.getQuantity(3, KILOGRAM) and Quantities.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 or equals(Quantity, epsilon, epsilonUnit) methods should be used.

        Overrides:
        equals in class AbstractQuantity<javax.measure.quantity.Time>
        Parameters:
        obj - the object to compare with.
        Returns:
        this.getUnit.equals(obj.getUnit()) && this.getLevel().equals(obj.getLevel() && this.getValue().equals(obj.getValue())
        Since:
        1.0
      • toString

        public String toString()
        Description copied from class: AbstractQuantity
        Returns the String representation 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 the QuantityFormat implementations and its subclasses.
        Overrides:
        toString in class AbstractQuantity<javax.measure.quantity.Time>
        Returns:
        SimpleQuantityFormat.getInstance().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)
      • multiply

        public ComparableQuantity<?> multiply​(javax.measure.Quantity<?> that)
        Since:
        1.0.1
        See Also:
        Quantity.multiply(Quantity)
      • negate

        public javax.measure.Quantity<javax.measure.quantity.Time> negate()
        Since:
        1.0.2