Class Aggregators
Aggregator
instances.
Min/Max/Average aggregators are type specific, so an integerAvg() aggregator expects all elements to be integers. There is no conversion executed while accumulating, so if there is any other type met an exception will be thrown.
In order to operate on a generic Number type use the fixedPointSum(), floatingPointSum() and numberAvg() aggregators. All of them will convert the given number to either Long or Double during the accumulation phase. It will result in a lot of allocations since each number has to be converted, but it enables the user to operate on the whole family of numbers. It is especially useful if the numbers given to the aggregators may not be of one type only.
The attributePath given in the factory method allows the aggregator to operate on the value extracted by navigating to the given attributePath on each object that has been returned from a query. The attribute path may be simple, e.g. "name", or nested "address.city".
If an aggregator does not accept null values pass a predicate to the aggregate call that will filter them out.
If the input value or the extracted value is a collection it won't be "unfolded" - so for example count aggregation on "person.postalCodes" will return 1 for each input object and not the size of the collection. In order to calculate the size of the collection use the [any] operator, e.g. "person.postalCodes[any]".
- Since:
- 3.8
-
Method Summary
Modifier and TypeMethodDescriptionstatic <I> Aggregator<I,
BigDecimal> static <I> Aggregator<I,
BigDecimal> bigDecimalAvg
(String attributePath) static <I> Aggregator<I,
BigDecimal> static <I> Aggregator<I,
BigDecimal> bigDecimalMax
(String attributePath) static <I> Aggregator<I,
BigDecimal> static <I> Aggregator<I,
BigDecimal> bigDecimalMin
(String attributePath) static <I> Aggregator<I,
BigDecimal> static <I> Aggregator<I,
BigDecimal> bigDecimalSum
(String attributePath) static <I> Aggregator<I,
BigDecimal> static <I> Aggregator<I,
BigDecimal> bigIntegerAvg
(String attributePath) static <I> Aggregator<I,
BigInteger> static <I> Aggregator<I,
BigInteger> bigIntegerMax
(String attributePath) static <I> Aggregator<I,
BigInteger> static <I> Aggregator<I,
BigInteger> bigIntegerMin
(String attributePath) static <I> Aggregator<I,
BigInteger> static <I> Aggregator<I,
BigInteger> bigIntegerSum
(String attributePath) static <I,
R extends Comparable>
Aggregator<I,R> static <I,
R extends Comparable>
Aggregator<I,R> comparableMax
(String attributePath) static <I,
R extends Comparable>
Aggregator<I,R> static <I,
R extends Comparable>
Aggregator<I,R> comparableMin
(String attributePath) static <I> Aggregator<I,
Long> count()
static <I> Aggregator<I,
Long> static <I,
R> Aggregator<I, Set<R>> distinct()
static <I,
R> Aggregator<I, Set<R>> static <I> Aggregator<I,
Double> static <I> Aggregator<I,
Double> static <I> Aggregator<I,
Double> static <I> Aggregator<I,
Double> static <I> Aggregator<I,
Double> static <I> Aggregator<I,
Double> static <I> Aggregator<I,
Double> static <I> Aggregator<I,
Double> static <I> Aggregator<I,
Long> static <I> Aggregator<I,
Long> fixedPointSum
(String attributePath) static <I> Aggregator<I,
Double> static <I> Aggregator<I,
Double> floatingPointSum
(String attributePath) static <I> Aggregator<I,
Double> static <I> Aggregator<I,
Double> integerAvg
(String attributePath) static <I> Aggregator<I,
Integer> static <I> Aggregator<I,
Integer> integerMax
(String attributePath) static <I> Aggregator<I,
Integer> static <I> Aggregator<I,
Integer> integerMin
(String attributePath) static <I> Aggregator<I,
Long> static <I> Aggregator<I,
Long> integerSum
(String attributePath) static <I> Aggregator<I,
Double> longAvg()
static <I> Aggregator<I,
Double> static <I> Aggregator<I,
Long> longMax()
static <I> Aggregator<I,
Long> static <I> Aggregator<I,
Long> longMin()
static <I> Aggregator<I,
Long> static <I> Aggregator<I,
Long> longSum()
static <I> Aggregator<I,
Long> static <I> Aggregator<I,
I> static <I> Aggregator<I,
I> static <I> Aggregator<I,
Double> static <I> Aggregator<I,
Double>
-
Method Details
-
count
- Type Parameters:
I
- type of the input object.- Returns:
- an aggregator that counts the input values. Accepts nulls as input values. Aggregation result type Long.
-
count
- Type Parameters:
I
- type of the input object.- Returns:
- an aggregator that counts the input values extracted from the given attributePath. Accepts null input values and null extracted values. Aggregation result type Long.
-
distinct
- Type Parameters:
I
- type of the input object.R
- type of the return object.- Returns:
- an aggregator that calculates the distinct set of input values. Accepts null input values. Aggregation result type is a Set of R.
-
distinct
- Type Parameters:
I
- type of the input object.R
- type of the return object.- Parameters:
attributePath
- the attribute path- Returns:
- an aggregator that calculates the distinct set of input values extracted from the given attributePath. Accepts null input values and null extracted values. Aggregation result type is a Set of R.
-
bigDecimalAvg
- Type Parameters:
I
- type of the input object.- Returns:
- an aggregator that calculates the average of the input values. Does NOT accept null input values. Accepts only BigDecimal input values. Aggregation result type is BigDecimal.
-
bigDecimalAvg
- Type Parameters:
I
- type of the input object.- Parameters:
attributePath
- the attribute path- Returns:
- an aggregator that calculates the average of the input values extracted from the given attributePath. Does NOT accept null input values nor null extracted values. Accepts only BigDecimal input values. Aggregation result type is BigDecimal.
-
bigIntegerAvg
- Type Parameters:
I
- type of the input object.- Returns:
- an aggregator that calculates the average of the input values. Does NOT accept null input values. Accepts only BigInteger input values. Aggregation result type is BigDecimal.
-
bigIntegerAvg
- Type Parameters:
I
- type of the input object.- Parameters:
attributePath
- the attribute path- Returns:
- an aggregator that calculates the average of the input values extracted from the given attributePath. Does NOT accept null input values nor null extracted values. Accepts only BigInteger input values. Aggregation result type is BigDecimal.
-
doubleAvg
- Type Parameters:
I
- type of the input object.- Returns:
- an aggregator that calculates the average of the input values. Does NOT accept null input values. Accepts only Double input values (primitive and boxed). Aggregation result type is Double.
-
doubleAvg
- Type Parameters:
I
- type of the input object.- Parameters:
attributePath
- the attribute path- Returns:
- an aggregator that calculates the average of the input values extracted from the given attributePath. Does NOT accept null input values nor null extracted values. Accepts only Double input values (primitive and boxed). Aggregation result type is Double.
-
integerAvg
- Type Parameters:
I
- type of the input object.- Returns:
- an aggregator that calculates the average of the input values. Does NOT accept null input values. Accepts only Integer input values (primitive and boxed). Aggregation result type is Double.
-
integerAvg
- Type Parameters:
I
- type of the input object.- Parameters:
attributePath
- the attribute path- Returns:
- an aggregator that calculates the average of the input values extracted from the given attributePath. Does NOT accept null input values nor null extracted values. Accepts only Integer input values (primitive and boxed). Aggregation result type is Double.
-
longAvg
- Type Parameters:
I
- type of the input object.- Returns:
- an aggregator that calculates the average of the input values. Does NOT accept null input values. Accepts only Long input values (primitive and boxed). Aggregation result type is Double.
-
longAvg
- Type Parameters:
I
- type of the input object.- Parameters:
attributePath
- the attribute path- Returns:
- an aggregator that calculates the average of the input values extracted from the given attributePath. Does NOT accept null input values nor null extracted values. Accepts only Long input values (primitive and boxed). Aggregation result type is Double.
-
numberAvg
- Type Parameters:
I
- type of the input object.- Returns:
- an aggregator that calculates the average of the input values. Does NOT accept null input values. Accepts generic Number input values. Aggregation result type is Double.
-
numberAvg
- Type Parameters:
I
- type of the input object.- Parameters:
attributePath
- the attribute path- Returns:
- an aggregator that calculates the average of the input values extracted from the given attributePath. Does NOT accept null input values nor null extracted values. Accepts generic Number input values. Aggregation result type is Double.
-
bigDecimalMax
- Type Parameters:
I
- type of the input object.- Returns:
- an aggregator that calculates the max of the input values. Accepts null input values. Accepts only BigDecimal input values. Aggregation result type is BigDecimal.
-
bigDecimalMax
- Type Parameters:
I
- type of the input object.- Parameters:
attributePath
- the attribute path- Returns:
- an aggregator that calculates the max of the input values extracted from the given attributePath. Accepts null input values and null extracted values. Accepts only BigDecimal input values. Aggregation result type is BigDecimal.
-
bigIntegerMax
- Type Parameters:
I
- type of the input object.- Returns:
- an aggregator that calculates the max of the input values. Accepts null input values and null extracted values. Accepts only BigInteger input values. Aggregation result type is BigInteger.
-
bigIntegerMax
- Type Parameters:
I
- type of the input object.- Parameters:
attributePath
- the attribute path- Returns:
- an aggregator that calculates the max of the input values extracted from the given attributePath. Accepts null input values nor null extracted values. Accepts only BigInteger input values. Aggregation result type is BigInteger.
-
doubleMax
- Type Parameters:
I
- type of the input object.- Returns:
- an aggregator that calculates the max of the input values. Accepts null input values and null extracted values. Accepts only Double input values (primitive and boxed). Aggregation result type is Double.
-
doubleMax
- Type Parameters:
I
- type of the input object.- Parameters:
attributePath
- the attribute path- Returns:
- an aggregator that calculates the max of the input values extracted from the given attributePath. Accepts null input values and null extracted values. Accepts only Double input values (primitive and boxed). Aggregation result type is Double.
-
integerMax
- Type Parameters:
I
- type of the input object.- Returns:
- an aggregator that calculates the max of the input values. Accepts null input values. Accepts only Integer input values (primitive and boxed). Aggregation result type is Integer.
-
integerMax
- Type Parameters:
I
- type of the input object.- Parameters:
attributePath
- the attribute path- Returns:
- an aggregator that calculates the max of the input values extracted from the given attributePath. Accepts null input values and null extracted values. Accepts only Integer input values (primitive and boxed). Aggregation result type is Integer.
-
longMax
- Type Parameters:
I
- type of the input object.- Returns:
- an aggregator that calculates the max of the input values. Accepts null input values. Accepts only Long input values (primitive and boxed). Aggregation result type is Long.
-
longMax
- Type Parameters:
I
- type of the input object.- Parameters:
attributePath
- the attribute path- Returns:
- an aggregator that calculates the max of the input values extracted from the given attributePath. Accepts null input values and null extracted values. Accepts only Long input values (primitive and boxed). Aggregation result type is Long.
-
comparableMax
- Type Parameters:
I
- type of the input object.R
- type of the return object (subtype of Comparable)- Returns:
- an aggregator that calculates the max of the input values. Accepts null input values. Accepts generic Comparable input values. Aggregation result type is R.
-
comparableMax
- Type Parameters:
I
- type of the input object.R
- type of the return object (subtype of Comparable)- Parameters:
attributePath
- the attribute path- Returns:
- an aggregator that calculates the max of the input values extracted from the given attributePath. Accepts null input values and null extracted values. Accepts generic Comparable input values. Aggregation result type is R.
-
maxBy
- Type Parameters:
I
- type of the input object.- Returns:
- an aggregator that calculates the max of the input values extracted from the given attributePath and returns the input item containing the maximum value. If multiple items contain the maximum value, any of them is returned. Accepts null input values and null extracted values. Accepts generic Comparable input values.
-
bigDecimalMin
- Type Parameters:
I
- type of the input object.- Returns:
- an aggregator that calculates the min of the input values. Accepts null input values and null extracted values. Accepts only BigDecimal input values. Aggregation result type is BigDecimal.
-
bigDecimalMin
- Type Parameters:
I
- type of the input object.- Parameters:
attributePath
- the attribute path- Returns:
- an aggregator that calculates the min of the input values extracted from the given attributePath. Accepts null input values and null extracted values. Accepts only BigDecimal input values. Aggregation result type is BigDecimal.
-
bigIntegerMin
- Type Parameters:
I
- type of the input object.- Returns:
- an aggregator that calculates the min of the input values. Accepts null input values and null extracted values. Accepts only BigInteger input values. Aggregation result type is BigInteger.
-
bigIntegerMin
- Type Parameters:
I
- type of the input object.- Parameters:
attributePath
- the attribute path- Returns:
- an aggregator that calculates the min of the input values extracted from the given attributePath. Accepts null input values and null extracted values. Accepts only BigInteger input values. Aggregation result type is BigInteger.
-
doubleMin
- Type Parameters:
I
- type of the input object.- Returns:
- an aggregator that calculates the min of the input values. Accepts null input values and null extracted values. Accepts only Double input values (primitive and boxed). Aggregation result type is Double.
-
doubleMin
- Type Parameters:
I
- type of the input object.- Parameters:
attributePath
- the attribute path- Returns:
- an aggregator that calculates the min of the input values extracted from the given attributePath. Accepts null input values and null extracted values. Accepts only Double input values (primitive and boxed). Aggregation result type is Double.
-
integerMin
- Type Parameters:
I
- type of the input object.- Returns:
- an aggregator that calculates the min of the input values. Accepts null input values and null extracted values. Accepts only Integer input values (primitive and boxed). Aggregation result type is Integer.
-
integerMin
- Type Parameters:
I
- type of the input object.- Parameters:
attributePath
- the attribute path- Returns:
- an aggregator that calculates the min of the input values extracted from the given attributePath. Accepts null input values and null extracted values. Accepts only Integer input values (primitive and boxed). Aggregation result type is Integer.
-
longMin
- Type Parameters:
I
- type of the input object.- Returns:
- an aggregator that calculates the min of the input values. Accepts null input values and null extracted values. Accepts only Long input values (primitive and boxed). Aggregation result type is Long.
-
longMin
- Type Parameters:
I
- type of the input object.- Parameters:
attributePath
- the attribute path- Returns:
- an aggregator that calculates the min of the input values extracted from the given attributePath. Accepts null input values and null extracted values. Accepts only Long input values (primitive and boxed). Aggregation result type is Long.
-
comparableMin
- Type Parameters:
I
- type of the input object.R
- type of the return object (subtype of Comparable)- Returns:
- an aggregator that calculates the min of the input values. Accepts null input values. Accepts generic Comparable input values. Aggregation result type is R.
-
comparableMin
- Type Parameters:
I
- type of the input object.R
- type of the return object (subtype of Comparable)- Parameters:
attributePath
- the attribute path- Returns:
- an aggregator that calculates the min of the input values extracted from the given attributePath. Accepts null input values and null extracted values. Accepts generic Comparable input values. Aggregation result type is R.
-
minBy
- Type Parameters:
I
- type of the input object.- Parameters:
attributePath
- the attribute path- Returns:
- an aggregator that calculates the min of the input values extracted from the given attributePath and returns the input item containing the minimum value. If multiple items contain the minimum value, any of them is returned. Accepts null input values and null extracted values. Accepts generic Comparable input values.
-
bigDecimalSum
- Type Parameters:
I
- type of the input object.- Returns:
- an aggregator that calculates the sum of the input values. Does NOT accept null input values. Accepts only BigDecimal input values. Aggregation result type is BigDecimal.
-
bigDecimalSum
- Type Parameters:
I
- type of the input object.- Parameters:
attributePath
- the attribute path- Returns:
- an aggregator that calculates the sum of the input values extracted from the given attributePath. Does NOT accept null input values nor null extracted values. Accepts only BigDecimal input values. Aggregation result type is BigDecimal.
-
bigIntegerSum
- Type Parameters:
I
- type of the input object.- Returns:
- an aggregator that calculates the sum of the input values. Does NOT accept null input values. Accepts only BigInteger input values. Aggregation result type is BigInteger.
-
bigIntegerSum
- Type Parameters:
I
- type of the input object.- Parameters:
attributePath
- the attribute path- Returns:
- an aggregator that calculates the sum of the input values extracted from the given attributePath. Does NOT accept null input values nor null extracted values. Accepts only BigInteger input values. Aggregation result type is BigInteger.
-
doubleSum
- Type Parameters:
I
- type of the input object.- Returns:
- an aggregator that calculates the sum of the input values. Does NOT accept null input values. Accepts only Double input values (primitive and boxed). Aggregation result type is Double.
-
doubleSum
- Type Parameters:
I
- type of the input object.- Parameters:
attributePath
- the attribute path- Returns:
- an aggregator that calculates the sum of the input values extracted from the given attributePath. Does NOT accept null input values. Accepts only Double input values (primitive and boxed). Aggregation result type is Double.
-
integerSum
- Type Parameters:
I
- type of the input object.- Returns:
- an aggregator that calculates the sum of the input values. Does NOT accept null input values. Accepts only Integer input values (primitive and boxed). Aggregation result type is Long.
-
integerSum
- Type Parameters:
I
- type of the input object.- Parameters:
attributePath
- the attribute path- Returns:
- an aggregator that calculates the sum of the input values extracted from the given attributePath. Does NOT accept null input values. Accepts only Integer input values (primitive and boxed). Aggregation result type is Long.
-
longSum
- Type Parameters:
I
- type of the input object.- Returns:
- an aggregator that calculates the sum of the input values. Does NOT accept null input values. Accepts only Long input values (primitive and boxed). Aggregation result type is Long.
-
longSum
- Type Parameters:
I
- type of the input object.- Parameters:
attributePath
- the attribute path- Returns:
- an aggregator that calculates the sum of the input values extracted from the given attributePath. Does NOT accept null input values. Accepts only Long input values (primitive and boxed). Aggregation result type is Long.
-
fixedPointSum
- Type Parameters:
I
- type of the input object.- Returns:
- an aggregator that calculates the sum of the input values. Does NOT accept null input values. Accepts generic Number input values. Aggregation result type is Long.
-
fixedPointSum
- Type Parameters:
I
- type of the input object.- Parameters:
attributePath
- the attribute path- Returns:
- an aggregator that calculates the sum of the input values extracted from the given attributePath. Does NOT accept null input values. Accepts generic Number input values. Aggregation result type is Long.
-
floatingPointSum
- Type Parameters:
I
- type of the input object.- Returns:
- an aggregator that calculates the sum of the input values. Does NOT accept null input values. Accepts generic Number input values. Aggregation result type is Double.
-
floatingPointSum
- Type Parameters:
I
- type of the input object.- Parameters:
attributePath
- the attribute path- Returns:
- an aggregator that calculates the sum of the input values extracted from the given attributePath. Does NOT accept null input values. Accepts generic Number input values. Aggregation result type is Double.
-