# Class Aggregation (3.1.0)

3.1.0 (latest) 2.40.0 2.37.0 2.36.0 2.34.0 2.33.3 2.32.3 2.31.4 2.30.0 2.29.1 2.28.2 2.27.1 2.26.4 2.25.2 2.24.3 2.23.0 2.22.0 2.21.3 2.20.2 2.19.2 2.18.5 2.17.6

    public abstract class Aggregation

Represents a Google Cloud Datastore Aggregation which is used with an [AggregationQuery](https://docs.cloud.google.com/java/docs/reference/google-cloud-datastore/latest/com.google.datastore.v1.AggregationQuery).

## Inheritance

[java.lang.Object](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html) \> Aggregation

## Inherited Members

[Object.clone()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#clone--) [Object.equals(Object)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-) [Object.finalize()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#finalize--) [Object.getClass()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#getClass--) [Object.hashCode()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--) [Object.notify()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notify--) [Object.notifyAll()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notifyAll--) [Object.toString()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--) [Object.wait()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait--) [Object.wait(long)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-) [Object.wait(long,int)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-int-)

## Static Methods

### avg(String propertyReference)

    public static AvgAggregation.Builder avg(String propertyReference)

Returns a [AvgAggregation](https://docs.cloud.google.com/java/docs/reference/google-cloud-datastore/latest/com.google.cloud.datastore.aggregation.AvgAggregation) builder.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `propertyReference` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-datastore/latest/com.google.cloud.datastore.aggregation.AvgAggregation.Builder` |   |

### count()

    public static CountAggregation.Builder count()

Returns a [CountAggregation](https://docs.cloud.google.com/java/docs/reference/google-cloud-datastore/latest/com.google.cloud.datastore.aggregation.CountAggregation) builder.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-datastore/latest/com.google.cloud.datastore.aggregation.CountAggregation.Builder` |   |

### sum(String propertyReference)

    public static SumAggregation.Builder sum(String propertyReference)

Returns a [SumAggregation](https://docs.cloud.google.com/java/docs/reference/google-cloud-datastore/latest/com.google.cloud.datastore.aggregation.SumAggregation) builder.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `propertyReference` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-datastore/latest/com.google.cloud.datastore.aggregation.SumAggregation.Builder` |   |

## Constructors

### Aggregation(String alias)

    public Aggregation(String alias)

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `alias` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |

## Methods

### aggregationBuilder()

    protected AggregationQuery.Aggregation.Builder aggregationBuilder()

> [!WARNING]
> **Internal Only**: This feature is not stable for application use.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-datastore/latest/com.google.datastore.v1.AggregationQuery.Aggregation.Builder` |   |

### getAlias()

    public String getAlias()

Returns the alias for this aggregation.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |   |

### toPb()

    public abstract AggregationQuery.Aggregation toPb()

> [!WARNING]
> **Internal Only**: This feature is not stable for application use.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-datastore/latest/com.google.datastore.v1.AggregationQuery.Aggregation` |   |