# DebouncedDataTypeCondition

Artifact: [androidx.health:health-services-client](https://developer.android.com/jetpack/androidx/releases/health) [View Source](https://cs.android.com/search?q=file:androidx/health/services/client/data/DebouncedDataTypeCondition.kt+class:androidx.health.services.client.data.DebouncedDataTypeCondition) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/health#1.1.0)

*** ** * ** ***


```
public final class DebouncedDataTypeCondition<T extends Number, D extends DataType<@NonNull T, @NonNull DataPoint<@NonNull T>>>
```

<br />

*** ** * ** ***

A condition which is considered met when a data type value passes a defined threshold for a specified duration.

## Summary

| ### Public methods |
|---|---|
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/health/services/client/data/DebouncedDataTypeCondition<@https://developer.android.com/reference/androidx/annotation/NonNull T, @https://developer.android.com/reference/androidx/annotation/NonNull D>` | `<T extends https://developer.android.com/reference/java/lang/Number.html, D extends https://developer.android.com/reference/androidx/health/services/client/data/AggregateDataType<@https://developer.android.com/reference/androidx/annotation/NonNull T, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/health/services/client/data/StatisticalDataPoint<@https://developer.android.com/reference/androidx/annotation/NonNull T>>> https://developer.android.com/reference/androidx/health/services/client/data/DebouncedDataTypeCondition#createDebouncedDataTypeCondition(androidx.health.services.client.data.AggregateDataType,kotlin.Number,androidx.health.services.client.data.ComparisonType,kotlin.Int,kotlin.Int)( @https://developer.android.com/reference/androidx/annotation/NonNull D dataType, @https://developer.android.com/reference/androidx/annotation/NonNull T threshold, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/health/services/client/data/ComparisonType comparisonType, int initialDelaySeconds, int durationAtThresholdSeconds )` Creates a `https://developer.android.com/reference/androidx/health/services/client/data/DebouncedDataTypeCondition` for an aggregate data type, whose value represents an average value, e.g. average heart rate over the tracking period, average speed over the tracking period. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/health/services/client/data/DebouncedDataTypeCondition<@https://developer.android.com/reference/androidx/annotation/NonNull T, @https://developer.android.com/reference/androidx/annotation/NonNull D>` | `<T extends https://developer.android.com/reference/java/lang/Number.html, D extends https://developer.android.com/reference/androidx/health/services/client/data/DeltaDataType<@https://developer.android.com/reference/androidx/annotation/NonNull T, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/health/services/client/data/SampleDataPoint<@https://developer.android.com/reference/androidx/annotation/NonNull T>>> https://developer.android.com/reference/androidx/health/services/client/data/DebouncedDataTypeCondition#createDebouncedDataTypeCondition(androidx.health.services.client.data.DeltaDataType,kotlin.Number,androidx.health.services.client.data.ComparisonType,kotlin.Int,kotlin.Int)( @https://developer.android.com/reference/androidx/annotation/NonNull D dataType, @https://developer.android.com/reference/androidx/annotation/NonNull T threshold, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/health/services/client/data/ComparisonType comparisonType, int initialDelaySeconds, int durationAtThresholdSeconds )` Creates a `https://developer.android.com/reference/androidx/health/services/client/data/DebouncedDataTypeCondition` for a sample data type, whose value represents an instantaneous value, e.g. instantaneous heart rate, instantaneous speed. |
| `boolean` | `https://developer.android.com/reference/androidx/health/services/client/data/DebouncedDataTypeCondition#equals(kotlin.Any)(https://developer.android.com/reference/java/lang/Object.html other)` |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/health/services/client/data/ComparisonType` | `https://developer.android.com/reference/androidx/health/services/client/data/DebouncedDataTypeCondition#getComparisonType()()` The comparison type to use when comparing the threshold against the current value. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull D` | `https://developer.android.com/reference/androidx/health/services/client/data/DebouncedDataTypeCondition#getDataType()()` `https://developer.android.com/reference/androidx/health/services/client/data/DataType` which this condition applies to. |
| `final int` | `https://developer.android.com/reference/androidx/health/services/client/data/DebouncedDataTypeCondition#getDurationAtThresholdSeconds()()` The amount of time (in seconds) the threshold must be crossed uninterruptedly for this goal to trigger. |
| `final int` | `https://developer.android.com/reference/androidx/health/services/client/data/DebouncedDataTypeCondition#getInitialDelaySeconds()()` The amount of time (in seconds) that must pass before the goal can trigger. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull T` | `https://developer.android.com/reference/androidx/health/services/client/data/DebouncedDataTypeCondition#getThreshold()()` The threshold at which point this condition should be met. |
| `int` | `https://developer.android.com/reference/androidx/health/services/client/data/DebouncedDataTypeCondition#hashCode()()` |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/health/services/client/data/DebouncedDataTypeCondition#toString()()` |

## Public methods

### createDebouncedDataTypeCondition

```
public static final @NonNull DebouncedDataTypeCondition<@NonNull T, @NonNull D> <T extends Number, D extends AggregateDataType<@NonNull T, @NonNull StatisticalDataPoint<@NonNull T>>> createDebouncedDataTypeCondition(
    @NonNull D dataType,
    @NonNull T threshold,
    @NonNull ComparisonType comparisonType,
    int initialDelaySeconds,
    int durationAtThresholdSeconds
)
```

Creates a `https://developer.android.com/reference/androidx/health/services/client/data/DebouncedDataTypeCondition` for an aggregate data type, whose value represents an average value, e.g. average heart rate over the tracking period, average speed over the tracking period.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull D dataType` | an aggregate data type that is associated with `https://developer.android.com/reference/androidx/health/services/client/data/StatisticalDataPoint`s, and whose value represents an average value over the tracking period |
| `@https://developer.android.com/reference/androidx/annotation/NonNull T threshold` | the threshold for the value of this data type to cross in order to satisfy the condition |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/health/services/client/data/ComparisonType comparisonType` | the way that determines how to compare the value of the data type with the threshold in the condition, e.g. greater than, less than or equal |
| `int initialDelaySeconds` | the amount of time (in seconds) that must pass before the goal can trigger. Must be greater or equal to zero |
| `int durationAtThresholdSeconds` | the amount of time (in seconds) the threshold must be crossed uninterruptedly for this goal to trigger. Must be greater or equal to zero |

### createDebouncedDataTypeCondition

```
public static final @NonNull DebouncedDataTypeCondition<@NonNull T, @NonNull D> <T extends Number, D extends DeltaDataType<@NonNull T, @NonNull SampleDataPoint<@NonNull T>>> createDebouncedDataTypeCondition(
    @NonNull D dataType,
    @NonNull T threshold,
    @NonNull ComparisonType comparisonType,
    int initialDelaySeconds,
    int durationAtThresholdSeconds
)
```

Creates a `https://developer.android.com/reference/androidx/health/services/client/data/DebouncedDataTypeCondition` for a sample data type, whose value represents an instantaneous value, e.g. instantaneous heart rate, instantaneous speed.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull D dataType` | a delta data type that is associated with `https://developer.android.com/reference/androidx/health/services/client/data/SampleDataPoint`s, and whose value represents an instantaneous value |
| `@https://developer.android.com/reference/androidx/annotation/NonNull T threshold` | the threshold for the value of this data type to cross in order to satisfy the condition |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/health/services/client/data/ComparisonType comparisonType` | the way that determines how to compare the value of the data type with the threshold in the condition, e.g. greater than, less than or equal |
| `int initialDelaySeconds` | the amount of time (in seconds) that must pass before the goal can trigger. Must be greater or equal to zero |
| `int durationAtThresholdSeconds` | the amount of time (in seconds) the threshold must be crossed uninterruptedly for this goal to trigger. Must be greater or equal to zero |

### equals

```
public boolean equals(Object other)
```

### getComparisonType

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/health#1.1.0)

```
public final @NonNull ComparisonType getComparisonType()
```

The comparison type to use when comparing the threshold against the current value.

### getDataType

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/health#1.1.0)

```
public final @NonNull D getDataType()
```

`https://developer.android.com/reference/androidx/health/services/client/data/DataType` which this condition applies to.

### getDurationAtThresholdSeconds

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/health#1.1.0)

```
public final int getDurationAtThresholdSeconds()
```

The amount of time (in seconds) the threshold must be crossed uninterruptedly for this goal to trigger. Applicable only for sample data types.

Each time the value moves off threshold will reset durationAtThresholdSec timer. For example: For a DebouncedDataTypeCondition(HeartRate, threshold=100.00, GREATER_THAN_OR_EQUAL, initialDelaySec=60, durationAtThresholdSec=10). If user HeartRate fluctuates around 100.00bpm in the following pattern,

1. from t=0s to t=56s: HeartRate=100

2. at t=57s: HeartRate=99.99

3. from t=58s: HeartRate=100.00. Then the condition will be met on t=68s, since the durationAtThreshold timer has reset at t=57s and expired at t=68s, and the initialDelay timer has expired at t=60s.

The default value is 0, which means once reached threshold, trigger immediately (if initialDelay has expired).

### getInitialDelaySeconds

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/health#1.1.0)

```
public final int getInitialDelaySeconds()
```

The amount of time (in seconds) that must pass before the goal can trigger. Applicable only for sample data types.

Example 1: For a DebouncedDataTypeCondition(HeartRate, threshold=100.00, GREATER_THAN_OR_EQUAL, initialDelaySec=60, durationAtThresholdSec=10). If user HeartRate stays above 100.00bpm from t=0s, then the condition will be met on t=60s, since this is when the value has exceeded threshold for consecutively 10 seconds and the 60 seconds of initialDelay has expired.

Example 2: For a DebouncedDataTypeCondition(HeartRate, threshold=100.00, GREATER_THAN_OR_EQUAL, initialDelaySec=5, durationAtThresholdSec=10). If user HeartRate stays above 100.00bpm from t=0s, then the condition will be met on t=10s, since this is when the value has exceeded threshold for consecutively 10 seconds and the 5 seconds of initialDelay has expired.

The default value is 0, which means trigger whenever the goal has reached threshold, or has reached threshold for a specified durationAtThreshold.

### getThreshold

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/health#1.1.0)

```
public final @NonNull T getThreshold()
```

The threshold at which point this condition should be met.

### hashCode

```
public int hashCode()
```

### toString

```
public @NonNull String toString()
```