# 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)

*** ** * ** ***


```
class DebouncedDataTypeCondition<T : Number, D : DataType<T, DataPoint<T>>>
```

<br />

*** ** * ** ***

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

## Summary

| ### Public companion functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/health/services/client/data/DebouncedDataTypeCondition<T, D>` | `<T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-number/index.html, D : https://developer.android.com/reference/kotlin/androidx/health/services/client/data/AggregateDataType<T, https://developer.android.com/reference/kotlin/androidx/health/services/client/data/StatisticalDataPoint<T>>> https://developer.android.com/reference/kotlin/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)( dataType: D, threshold: T, comparisonType: https://developer.android.com/reference/kotlin/androidx/health/services/client/data/ComparisonType, initialDelaySeconds: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, durationAtThresholdSeconds: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html )` Creates a `https://developer.android.com/reference/kotlin/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. |
| `https://developer.android.com/reference/kotlin/androidx/health/services/client/data/DebouncedDataTypeCondition<T, D>` | `<T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-number/index.html, D : https://developer.android.com/reference/kotlin/androidx/health/services/client/data/DeltaDataType<T, https://developer.android.com/reference/kotlin/androidx/health/services/client/data/SampleDataPoint<T>>> https://developer.android.com/reference/kotlin/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)( dataType: D, threshold: T, comparisonType: https://developer.android.com/reference/kotlin/androidx/health/services/client/data/ComparisonType, initialDelaySeconds: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, durationAtThresholdSeconds: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html )` Creates a `https://developer.android.com/reference/kotlin/androidx/health/services/client/data/DebouncedDataTypeCondition` for a sample data type, whose value represents an instantaneous value, e.g. instantaneous heart rate, instantaneous speed. |

| ### Public functions |
|---|---|
| `open operator https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/health/services/client/data/DebouncedDataTypeCondition#equals(kotlin.Any)(other: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?)` |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/health/services/client/data/DebouncedDataTypeCondition#hashCode()()` |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/health/services/client/data/DebouncedDataTypeCondition#toString()()` |

| ### Public properties |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/health/services/client/data/ComparisonType` | `https://developer.android.com/reference/kotlin/androidx/health/services/client/data/DebouncedDataTypeCondition#comparisonType()` The comparison type to use when comparing the threshold against the current value. |
| `D` | `https://developer.android.com/reference/kotlin/androidx/health/services/client/data/DebouncedDataTypeCondition#dataType()` `https://developer.android.com/reference/kotlin/androidx/health/services/client/data/DataType` which this condition applies to. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/health/services/client/data/DebouncedDataTypeCondition#durationAtThresholdSeconds()` The amount of time (in seconds) the threshold must be crossed uninterruptedly for this goal to trigger. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/health/services/client/data/DebouncedDataTypeCondition#initialDelaySeconds()` The amount of time (in seconds) that must pass before the goal can trigger. |
| `T` | `https://developer.android.com/reference/kotlin/androidx/health/services/client/data/DebouncedDataTypeCondition#threshold()` The threshold at which point this condition should be met. |

## Public companion functions

### createDebouncedDataTypeCondition

```
fun <T : Number, D : AggregateDataType<T, StatisticalDataPoint<T>>> createDebouncedDataTypeCondition(
    dataType: D,
    threshold: T,
    comparisonType: ComparisonType,
    initialDelaySeconds: Int,
    durationAtThresholdSeconds: Int
): DebouncedDataTypeCondition<T, D>
```

Creates a `https://developer.android.com/reference/kotlin/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 |
|---|---|
| `dataType: D` | an aggregate data type that is associated with `https://developer.android.com/reference/kotlin/androidx/health/services/client/data/StatisticalDataPoint`s, and whose value represents an average value over the tracking period |
| `threshold: T` | the threshold for the value of this data type to cross in order to satisfy the condition |
| `comparisonType: https://developer.android.com/reference/kotlin/androidx/health/services/client/data/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 |
| `initialDelaySeconds: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | the amount of time (in seconds) that must pass before the goal can trigger. Must be greater or equal to zero |
| `durationAtThresholdSeconds: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | 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

```
fun <T : Number, D : DeltaDataType<T, SampleDataPoint<T>>> createDebouncedDataTypeCondition(
    dataType: D,
    threshold: T,
    comparisonType: ComparisonType,
    initialDelaySeconds: Int,
    durationAtThresholdSeconds: Int
): DebouncedDataTypeCondition<T, D>
```

Creates a `https://developer.android.com/reference/kotlin/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 |
|---|---|
| `dataType: D` | a delta data type that is associated with `https://developer.android.com/reference/kotlin/androidx/health/services/client/data/SampleDataPoint`s, and whose value represents an instantaneous value |
| `threshold: T` | the threshold for the value of this data type to cross in order to satisfy the condition |
| `comparisonType: https://developer.android.com/reference/kotlin/androidx/health/services/client/data/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 |
| `initialDelaySeconds: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | the amount of time (in seconds) that must pass before the goal can trigger. Must be greater or equal to zero |
| `durationAtThresholdSeconds: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | the amount of time (in seconds) the threshold must be crossed uninterruptedly for this goal to trigger. Must be greater or equal to zero |

## Public functions

### equals

```
open operator fun equals(other: Any?): Boolean
```

### hashCode

```
open fun hashCode(): Int
```

### toString

```
open fun toString(): String
```

## Public properties

### comparisonType

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

```
val comparisonType: ComparisonType
```

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

### dataType

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

```
val dataType: D
```

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

### durationAtThresholdSeconds

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

```
val durationAtThresholdSeconds: Int
```

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).

### initialDelaySeconds

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

```
val initialDelaySeconds: Int
```

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.

### threshold

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

```
val threshold: T
```

The threshold at which point this condition should be met.