Class QuantityFunctions

    • Method Summary

      Modifier and Type Method Description
      static <Q extends javax.measure.Quantity<Q>>
      Predicate<javax.measure.Quantity<Q>>
      fiterByExcludingUnit​(javax.measure.Unit<Q>... units)
      Predicate to filter excluding these units
      static <Q extends javax.measure.Quantity<Q>>
      Predicate<javax.measure.Quantity<Q>>
      fiterByUnit​(javax.measure.Unit<Q>... units)
      Predicate to filter to one or more units
      static <Q extends javax.measure.Quantity<Q>>
      Function<javax.measure.Quantity<Q>,​javax.measure.Unit<Q>>
      groupByUnit()
      creates a function to group quantities by their unit.
      static <Q extends javax.measure.Quantity<Q>>
      Predicate<javax.measure.Quantity<Q>>
      isBetween​(Number min, Number max)
      creates a Filter to between, lesser or equals and greater or equals, than number, ignoring units
      static <Q extends javax.measure.Quantity<Q>>
      Predicate<javax.measure.Quantity<Q>>
      isBetween​(javax.measure.Quantity<Q> min, javax.measure.Quantity<Q> max)
      creates a filter to between, lesser or equals and greater or equals, than the quantity measure
      static <Q extends javax.measure.Quantity<Q>>
      Predicate<javax.measure.Quantity<Q>>
      isGreaterThan​(Number value)
      creates a Filter to greater than number, ignoring units
      static <Q extends javax.measure.Quantity<Q>>
      Predicate<javax.measure.Quantity<Q>>
      isGreaterThan​(javax.measure.Quantity<Q> quantity)
      creates a filter to greater than the quantity measure
      static <Q extends javax.measure.Quantity<Q>>
      Predicate<javax.measure.Quantity<Q>>
      isGreaterThanOrEqualTo​(Number value)
      creates a Filter to greater or equals than number, ignoring units
      static <Q extends javax.measure.Quantity<Q>>
      Predicate<javax.measure.Quantity<Q>>
      isGreaterThanOrEqualTo​(javax.measure.Quantity<Q> quantity)
      creates a filter to greater or equals than the quantity measure
      static <Q extends javax.measure.Quantity<Q>>
      Predicate<javax.measure.Quantity<Q>>
      isLessThan​(Number value)
      creates a Filter to lesser than number, ignoring units
      static <Q extends javax.measure.Quantity<Q>>
      Predicate<javax.measure.Quantity<Q>>
      isLessThan​(javax.measure.Quantity<Q> quantity)
      creates a filter to lesser than the quantity measure
      static <Q extends javax.measure.Quantity<Q>>
      Predicate<javax.measure.Quantity<Q>>
      isLessThanOrEqualTo​(Number value)
      creates a Filter to lesser or equals than number, ignoring units
      static <Q extends javax.measure.Quantity<Q>>
      Predicate<javax.measure.Quantity<Q>>
      isLessThanOrEqualTo​(javax.measure.Quantity<Q> quantity)
      creates a filter to lesser or equals than the quantity measure
      static <Q extends javax.measure.Quantity<Q>>
      BinaryOperator<javax.measure.Quantity<Q>>
      max()
      Creates a BinaryOperator to calculate the maximum Quantity
      static <Q extends javax.measure.Quantity<Q>>
      BinaryOperator<javax.measure.Quantity<Q>>
      min()
      Creates a BinaryOperator to calculate the minimum Quantity
      static <Q extends javax.measure.Quantity<Q>>
      Comparator<javax.measure.Quantity<Q>>
      sortNatural()
      Creates a comparator to sort by natural order, looking to both the unit and the value.
      static <Q extends javax.measure.Quantity<Q>>
      Comparator<javax.measure.Quantity<Q>>
      sortNaturalDesc()
      Creates a comparator to sort by natural order descending, looking to both the unit and the value.
      static <Q extends javax.measure.Quantity<Q>>
      Comparator<javax.measure.Quantity<Q>>
      sortNumber()
      Creates a comparator to sort by number, ignoring the unit.
      static <Q extends javax.measure.Quantity<Q>>
      Comparator<javax.measure.Quantity<Q>>
      sortNumberDesc()
      Creates a comparator to sort by number descending, ignoring the unit.
      static <Q extends javax.measure.Quantity<Q>>
      Comparator<javax.measure.Quantity<Q>>
      sortSymbol()
      Creates a comparator to sort by name, ignoring the value.
      static <Q extends javax.measure.Quantity<Q>>
      Comparator<javax.measure.Quantity<Q>>
      sortSymbolDesc()
      Creates a comparator to sort by name descending, ignoring the value.
      static <Q extends javax.measure.Quantity<Q>>
      BinaryOperator<javax.measure.Quantity<Q>>
      sum()
      Creates a BinaryOperator to sum.
      static <Q extends javax.measure.Quantity<Q>>
      BinaryOperator<javax.measure.Quantity<Q>>
      sum​(javax.measure.Unit<Q> unit)
      Creates a BinaryOperator to sum converting to unit
    • Method Detail

      • sortNumber

        public static <Q extends javax.measure.Quantity<Q>> Comparator<javax.measure.Quantity<Q>> sortNumber()
        Creates a comparator to sort by number, ignoring the unit.
        Type Parameters:
        Q - the type of quantity
        Returns:

        Given:

        Quantity<Time> day = timeFactory.create(1, Units.DAY);
        Quantity<Time> hours = timeFactory.create(18, Units.HOUR);
        Quantity<Time> minutes = timeFactory.create(15, Units.HOUR);
        Quantity<Time> seconds = timeFactory.create(100, Units.HOUR);

        will return: day, hours, minutes, seconds

        Throws:
        NullPointerException - if any of the values to compare is null
      • sortNumberDesc

        public static <Q extends javax.measure.Quantity<Q>> Comparator<javax.measure.Quantity<Q>> sortNumberDesc()
        Creates a comparator to sort by number descending, ignoring the unit.
        Type Parameters:
        Q - the type of quantity
        Returns:

        Given:

        Quantity<Time> day = timeFactory.create(1, Units.DAY);
        Quantity<Time> hours = timeFactory.create(18, Units.HOUR);
        Quantity<Time> minutes = timeFactory.create(15, Units.HOUR);
        Quantity<Time> seconds = timeFactory.create(100, Units.HOUR);

        will return: seconds, hours, minutes, day

        Throws:
        NullPointerException - if any of the values to compare is null
      • sortSymbol

        public static <Q extends javax.measure.Quantity<Q>> Comparator<javax.measure.Quantity<Q>> sortSymbol()
        Creates a comparator to sort by name, ignoring the value.
        Type Parameters:
        Q - the type of quantity
        Returns:

        Given:

        Quantity<Time> day = timeFactory.create(1, Units.DAY);
        Quantity<Time> hours = timeFactory.create(18, Units.HOUR);
        Quantity<Time> minutes = timeFactory.create(15, Units.HOUR);
        Quantity<Time> seconds = timeFactory.create(100, Units.HOUR);

        will return: day, hours, minutes, seconds

        Throws:
        NullPointerException - if any of the values to compare is null
      • sortSymbolDesc

        public static <Q extends javax.measure.Quantity<Q>> Comparator<javax.measure.Quantity<Q>> sortSymbolDesc()
        Creates a comparator to sort by name descending, ignoring the value.
        Type Parameters:
        Q - the type of quantity
        Returns:

        Given:

        Quantity<Time> day = timeFactory.create(1, Units.DAY);
        Quantity<Time> hours = timeFactory.create(18, Units.HOUR);
        Quantity<Time> minutes = timeFactory.create(15, Units.HOUR);
        Quantity<Time> seconds = timeFactory.create(100, Units.HOUR);

        will return: seconds, minutes, hour, day

        Throws:
        NullPointerException - if any of the values to compare is null
      • sortNatural

        public static <Q extends javax.measure.Quantity<Q>> Comparator<javax.measure.Quantity<Q>> sortNatural()
        Creates a comparator to sort by natural order, looking to both the unit and the value.
        Type Parameters:
        Q - the type of quantity
        Returns:

        Given:

        Quantity<Time> day = timeFactory.create(1, Units.DAY);
        Quantity<Time> hours = timeFactory.create(18, Units.HOUR);
        Quantity<Time> minutes = timeFactory.create(15, Units.HOUR);
        Quantity<Time> seconds = timeFactory.create(100, Units.HOUR);

        will return: seconds, minutes, hours, day

        Throws:
        NullPointerException - if any of the values to compare is null
      • sortNaturalDesc

        public static <Q extends javax.measure.Quantity<Q>> Comparator<javax.measure.Quantity<Q>> sortNaturalDesc()
        Creates a comparator to sort by natural order descending, looking to both the unit and the value.
        Type Parameters:
        Q - the type of quantity
        Returns:

        Given:

        Quantity<Time> day = timeFactory.create(1, Units.DAY);
        Quantity<Time> hours = timeFactory.create(18, Units.HOUR);
        Quantity<Time> minutes = timeFactory.create(15, Units.HOUR);
        Quantity<Time> seconds = timeFactory.create(100, Units.HOUR);

        will return: day, hour, minute, second

        Throws:
        NullPointerException - if any of the values to compare is null
      • min

        public static <Q extends javax.measure.Quantity<Q>> BinaryOperator<javax.measure.Quantity<Q>> min()
        Creates a BinaryOperator to calculate the minimum Quantity
        Type Parameters:
        Q - the type of quantity
        Returns:
        the min BinaryOperator, not null.
      • max

        public static <Q extends javax.measure.Quantity<Q>> BinaryOperator<javax.measure.Quantity<Q>> max()
        Creates a BinaryOperator to calculate the maximum Quantity
        Type Parameters:
        Q - the type of quantity
        Returns:
        the max BinaryOperator, not null.
      • sum

        public static <Q extends javax.measure.Quantity<Q>> BinaryOperator<javax.measure.Quantity<Q>> sum()
        Creates a BinaryOperator to sum.
        Type Parameters:
        Q - the type of quantity
        Returns:
        the sum BinaryOperator
      • sum

        public static <Q extends javax.measure.Quantity<Q>> BinaryOperator<javax.measure.Quantity<Q>> sum​(javax.measure.Unit<Q> unit)
        Creates a BinaryOperator to sum converting to unit
        Type Parameters:
        Q - the type of quantity
        Parameters:
        unit - unit to be converting
        Returns:
        the sum BinaryOperator converting to unit
      • fiterByUnit

        @SafeVarargs
        public static <Q extends javax.measure.Quantity<Q>> Predicate<javax.measure.Quantity<Q>> fiterByUnit​(javax.measure.Unit<Q>... units)
        Predicate to filter to one or more units
        Type Parameters:
        Q - the type of quantity
        Parameters:
        units - - units to be filtered (optional)
        Returns:
        A predicate to filter one or more units
      • fiterByExcludingUnit

        @SafeVarargs
        public static <Q extends javax.measure.Quantity<Q>> Predicate<javax.measure.Quantity<Q>> fiterByExcludingUnit​(javax.measure.Unit<Q>... units)
        Predicate to filter excluding these units
        Type Parameters:
        Q - the type of quantity
        Parameters:
        units - - units to be filtered (optional)
        Returns:
        A predicate to filter to not be these units
      • isGreaterThan

        public static <Q extends javax.measure.Quantity<Q>> Predicate<javax.measure.Quantity<Q>> isGreaterThan​(Number value)
        creates a Filter to greater than number, ignoring units
        Type Parameters:
        Q - the type of quantity
        Parameters:
        value - - the value to be used in Predicate
        Returns:
        the Predicate greater than this number, ignoring units
      • isGreaterThan

        public static <Q extends javax.measure.Quantity<Q>> Predicate<javax.measure.Quantity<Q>> isGreaterThan​(javax.measure.Quantity<Q> quantity)
        creates a filter to greater than the quantity measure
        Type Parameters:
        Q - the type of quantity
        Parameters:
        quantity - - the measure to be used in filter
        Returns:
        the Predicate greater than this measure
      • isGreaterThanOrEqualTo

        public static <Q extends javax.measure.Quantity<Q>> Predicate<javax.measure.Quantity<Q>> isGreaterThanOrEqualTo​(Number value)
        creates a Filter to greater or equals than number, ignoring units
        Type Parameters:
        Q - the type of quantity
        Parameters:
        value - - the value to be used in Predicate
        Returns:
        the Predicate greater or equals than this number, ignoring units
      • isGreaterThanOrEqualTo

        public static <Q extends javax.measure.Quantity<Q>> Predicate<javax.measure.Quantity<Q>> isGreaterThanOrEqualTo​(javax.measure.Quantity<Q> quantity)
        creates a filter to greater or equals than the quantity measure
        Type Parameters:
        Q - the type of quantity
        Parameters:
        quantity - - the measure to be used in filter
        Returns:
        the Predicate greater or equals than this measure
      • isLessThan

        public static <Q extends javax.measure.Quantity<Q>> Predicate<javax.measure.Quantity<Q>> isLessThan​(Number value)
        creates a Filter to lesser than number, ignoring units
        Type Parameters:
        Q - the type of quantity
        Parameters:
        value - - the value to be used in Predicate
        Returns:
        the Predicate greater than this number, ignoring units
      • isLessThan

        public static <Q extends javax.measure.Quantity<Q>> Predicate<javax.measure.Quantity<Q>> isLessThan​(javax.measure.Quantity<Q> quantity)
        creates a filter to lesser than the quantity measure
        Type Parameters:
        Q - the type of quantity
        Parameters:
        quantity - - the measure to be used in filter
        Returns:
        the Predicate lesser than this measure
      • isLessThanOrEqualTo

        public static <Q extends javax.measure.Quantity<Q>> Predicate<javax.measure.Quantity<Q>> isLessThanOrEqualTo​(Number value)
        creates a Filter to lesser or equals than number, ignoring units
        Type Parameters:
        Q - the type of quantity
        Parameters:
        value - - the value to be used in Predicate
        Returns:
        the Predicate lesser or equals than this number, ignoring units
      • isLessThanOrEqualTo

        public static <Q extends javax.measure.Quantity<Q>> Predicate<javax.measure.Quantity<Q>> isLessThanOrEqualTo​(javax.measure.Quantity<Q> quantity)
        creates a filter to lesser or equals than the quantity measure
        Type Parameters:
        Q - the type of quantity
        Parameters:
        quantity - - the measure to be used in filter
        Returns:
        the Predicate lesser or equals than this measure
      • isBetween

        public static <Q extends javax.measure.Quantity<Q>> Predicate<javax.measure.Quantity<Q>> isBetween​(Number min,
                                                                                                           Number max)
        creates a Filter to between, lesser or equals and greater or equals, than number, ignoring units
        Type Parameters:
        Q - the type of quantity
        Parameters:
        min - - the min value to be used in Predicate
        max - - the max value to be used in Predicate
        Returns:
        the Predicate lesser or equals than this number, ignoring units
      • isBetween

        public static <Q extends javax.measure.Quantity<Q>> Predicate<javax.measure.Quantity<Q>> isBetween​(javax.measure.Quantity<Q> min,
                                                                                                           javax.measure.Quantity<Q> max)
        creates a filter to between, lesser or equals and greater or equals, than the quantity measure
        Type Parameters:
        Q - the type of quantity
        Parameters:
        min - - the min value to be used in Predicate
        max - - the max value to be used in Predicate
        Returns:
        the Predicate lesser or equals than this measure
      • groupByUnit

        public static <Q extends javax.measure.Quantity<Q>> Function<javax.measure.Quantity<Q>,​javax.measure.Unit<Q>> groupByUnit()
        creates a function to group quantities by their unit.
        Type Parameters:
        Q - the type of quantity
        Returns:
        the Function of Quantity grouped by Unit