public class AggregateFunctionA class that represents an aggregate function.
Static Methods
average(Expression expression)
public static AggregateFunction average(Expression expression)Creates an aggregation that calculates the average (mean) of values from an expression across multiple stage inputs.
| Parameter | |
|---|---|
| Name | Description |
expression |
ExpressionThe expression representing the values to average. |
| Returns | |
|---|---|
| Type | Description |
AggregateFunction |
A new AggregateFunction representing the average aggregation. |
average(String fieldName)
public static AggregateFunction average(String fieldName)Creates an aggregation that calculates the average (mean) of a field's values across multiple stage inputs.
| Parameter | |
|---|---|
| Name | Description |
fieldName |
StringThe name of the field containing numeric values to average. |
| Returns | |
|---|---|
| Type | Description |
AggregateFunction |
A new AggregateFunction representing the average aggregation. |
count(Expression expression)
public static AggregateFunction count(Expression expression)Creates an aggregation that counts the number of stage inputs with valid evaluations of the
provided expression.
| Parameter | |
|---|---|
| Name | Description |
expression |
ExpressionThe expression to count. |
| Returns | |
|---|---|
| Type | Description |
AggregateFunction |
A new AggregateFunction representing the 'count' aggregation. |
count(String fieldName)
public static AggregateFunction count(String fieldName)Creates an aggregation that counts the number of stage inputs where the input field exists.
| Parameter | |
|---|---|
| Name | Description |
fieldName |
StringThe name of the field to count. |
| Returns | |
|---|---|
| Type | Description |
AggregateFunction |
A new AggregateFunction representing the 'count' aggregation. |
countAll()
public static AggregateFunction countAll()Creates an aggregation that counts the total number of stage inputs.
| Returns | |
|---|---|
| Type | Description |
AggregateFunction |
A new AggregateFunction representing the countAll aggregation. |
countDistinct(Expression expression)
public static AggregateFunction countDistinct(Expression expression)Creates an aggregation that counts the number of distinct values of an expression across multiple stage inputs.
| Parameter | |
|---|---|
| Name | Description |
expression |
ExpressionThe expression to count the distinct values of. |
| Returns | |
|---|---|
| Type | Description |
AggregateFunction |
A new AggregateFunction representing the count distinct aggregation. |
countDistinct(String fieldName)
public static AggregateFunction countDistinct(String fieldName)Creates an aggregation that counts the number of distinct values of a field across multiple stage inputs.
| Parameter | |
|---|---|
| Name | Description |
fieldName |
StringThe name of the field to count the distinct values of. |
| Returns | |
|---|---|
| Type | Description |
AggregateFunction |
A new AggregateFunction representing the count distinct aggregation. |
countIf(BooleanExpression condition)
public static AggregateFunction countIf(BooleanExpression condition)Creates an aggregation that counts the number of stage inputs where the provided boolean expression evaluates to true.
| Parameter | |
|---|---|
| Name | Description |
condition |
BooleanExpressionThe boolean expression to evaluate on each input. |
| Returns | |
|---|---|
| Type | Description |
AggregateFunction |
A new AggregateFunction representing the count aggregation. |
maximum(Expression expression)
public static AggregateFunction maximum(Expression expression)Creates an aggregation that finds the maximum value of an expression across multiple stage inputs.
| Parameter | |
|---|---|
| Name | Description |
expression |
ExpressionThe expression to find the maximum value of. |
| Returns | |
|---|---|
| Type | Description |
AggregateFunction |
A new AggregateFunction representing the maximum aggregation. |
maximum(String fieldName)
public static AggregateFunction maximum(String fieldName)Creates an aggregation that finds the maximum value of a field across multiple stage inputs.
| Parameter | |
|---|---|
| Name | Description |
fieldName |
StringThe name of the field to find the maximum value of. |
| Returns | |
|---|---|
| Type | Description |
AggregateFunction |
A new AggregateFunction representing the maximum aggregation. |
minimum(Expression expression)
public static AggregateFunction minimum(Expression expression)Creates an aggregation that finds the minimum value of an expression across multiple stage inputs.
| Parameter | |
|---|---|
| Name | Description |
expression |
ExpressionThe expression to find the minimum value of. |
| Returns | |
|---|---|
| Type | Description |
AggregateFunction |
A new AggregateFunction representing the minimum aggregation. |
minimum(String fieldName)
public static AggregateFunction minimum(String fieldName)Creates an aggregation that finds the minimum value of a field across multiple stage inputs.
| Parameter | |
|---|---|
| Name | Description |
fieldName |
StringThe name of the field to find the minimum value of. |
| Returns | |
|---|---|
| Type | Description |
AggregateFunction |
A new AggregateFunction representing the minimum aggregation. |
rawAggregate(String name, Expression[] expr)
public static AggregateFunction rawAggregate(String name, Expression[] expr)Creates a raw aggregation function.
This method provides a way to call aggregation functions that are supported by the Firestore backend but that are not available as specific factory methods in this class.
| Parameters | |
|---|---|
| Name | Description |
name |
StringThe name of the aggregation function. |
expr |
Expression[]The expressions to pass as arguments to the function. |
| Returns | |
|---|---|
| Type | Description |
AggregateFunction |
A new AggregateFunction for the specified function. |
sum(Expression expression)
public static AggregateFunction sum(Expression expression)Creates an aggregation that calculates the sum of values from an expression across multiple stage inputs.
| Parameter | |
|---|---|
| Name | Description |
expression |
ExpressionThe expression to sum up. |
| Returns | |
|---|---|
| Type | Description |
AggregateFunction |
A new AggregateFunction representing the sum aggregation. |
sum(String fieldName)
public static AggregateFunction sum(String fieldName)Creates an aggregation that calculates the sum of a field's values across multiple stage inputs.
| Parameter | |
|---|---|
| Name | Description |
fieldName |
StringThe name of the field containing numeric values to sum up. |
| Returns | |
|---|---|
| Type | Description |
AggregateFunction |
A new AggregateFunction representing the sum aggregation. |
Methods
as(String alias)
public AliasedAggregate as(String alias)Assigns an alias to this aggregate.
| Parameter | |
|---|---|
| Name | Description |
alias |
StringThe alias to assign to this aggregate. |
| Returns | |
|---|---|
| Type | Description |
AliasedAggregate |
A new AliasedAggregate that wraps this aggregate and associates it with the provided alias. |