Class MixedQuantity<Q extends Quantity<Q>>

    • Constructor Detail

      • MixedQuantity

        protected MixedQuantity​(List<Quantity<Q>> quantities)
        Parameters:
        quantities - - the list of quantities to construct this MixedQuantity.
    • Method Detail

      • of

        @SafeVarargs
        public static <Q extends Quantity<Q>> MixedQuantity<Q> of​(Quantity<Q>... quantities)
        Type Parameters:
        Q -
        Parameters:
        quantities -
        Returns:
        a MixedQuantity with the specified quantities
        Throws:
        IllegalArgumentException - if given quantities is null or empty or contains any null values or contains quantities of mixed scale
      • of

        public static <Q extends Quantity<Q>> MixedQuantity<Q> of​(List<Quantity<Q>> quantities)
        Type Parameters:
        Q -
        Parameters:
        quantities -
        Returns:
        a MixedQuantity with the specified quantities
        Throws:
        IllegalArgumentException - if given quantities is null or empty or contains any null values or contains quantities of mixed scale
      • getUnits

        public List<Unit<Q>> getUnits()
        Gets the list of units in this MixedQuantity.

        This list can be used in conjunction with getQuantities() to access the entire quantity.

        Returns:
        a list containing the units, not null
      • getQuantities

        public List<Quantity<Q>> getQuantities()
        Gets quantities in this MixedQuantity.
        Returns:
        a list containing the quantities, not null
      • to

        public Quantity<Qto​(Unit<Q> unit)
        Returns the sum of all quantity values in this MixedQuantity converted into another (compatible) unit.
        Specified by:
        to in interface tech.uom.lib.common.function.QuantityConverter<Q extends Quantity<Q>>
        Parameters:
        unit - the Unit unit in which the returned quantity is stated.
        Returns:
        the sum of all quantities in this MixedQuantity or a new quantity stated in the specified unit.
        Throws:
        ArithmeticException - if the result is inexact and the quotient has a non-terminating decimal expansion.
      • equals

        public boolean equals​(Object obj)
        Indicates if this mixed quantity is considered equal to the specified object (both are mixed units with same composing units in the same order).
        Overrides:
        equals in class Object
        Parameters:
        obj - the object to compare for equality.
        Returns:
        true if this and obj are considered equal; falseotherwise.