AggregationResult
public final class AggregationResult
Contains results of requested AggregateMetric.
To retrieve aggregate metrics:
val result = healthConnectClient.aggregate(
metrics = setOf(Steps.COUNT_TOTAL, Distance.DISTANCE_TOTAL)
)
val totalSteps = result[Steps.COUNT_TOTAL]
val totalDistance = result[Distance.DISTANCE_TOTAL]
| See also | |
|---|---|
aggregate |
Summary
Public methods |
|
|---|---|
final boolean |
contains(@NonNull AggregateMetric<@NonNull ?> metric)Checks whether the aggregation result contains a metric or not. |
boolean |
|
final T |
<T extends Object> get(@NonNull AggregateMetric<@NonNull T> metric)Retrieves a metric with given metric identifier. |
final @NonNull Set<@NonNull DataOrigin> |
Set of |
int |
hashCode() |
@NonNull String |
toString() |
Public methods
contains
public final boolean contains(@NonNull AggregateMetric<@NonNull ?> metric)
Checks whether the aggregation result contains a metric or not. If there is no relevant record that contribute to requested metric, the metric will not be provided.
| Parameters | |
|---|---|
@NonNull AggregateMetric<@NonNull ?> metric |
an aggregate metric identifier. |
| Returns | |
|---|---|
boolean |
whether given metric is set. |
get
public final T <T extends Object> get(@NonNull AggregateMetric<@NonNull T> metric)
Retrieves a metric with given metric identifier.
If there are no relevant records contributing to the requested metric, the metric will not be provided.
| Returns | |
|---|---|
T |
the value of the metric, or null if not set. |
| See also | |
|---|---|
contains |
getDataOrigins
public final @NonNull Set<@NonNull DataOrigin> getDataOrigins()
Set of DataOrigins that contributed to the aggregation result.