DebouncedDataTypeCondition


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


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

Summary

Public methods

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 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 @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 DebouncedDataTypeCondition for a sample data type, whose value represents an instantaneous value, e.g. instantaneous heart rate, instantaneous speed.

boolean
equals(Object other)
final @NonNull ComparisonType

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

final @NonNull D

DataType which this condition applies to.

final int

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

final int

The amount of time (in seconds) that must pass before the goal can trigger.

final @NonNull T

The threshold at which point this condition should be met.

int
@NonNull String

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 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
@NonNull D dataType

an aggregate data type that is associated with StatisticalDataPoints, and whose value represents an average value over the tracking period

@NonNull T threshold

the threshold for the value of this data type to cross in order to satisfy the condition

@NonNull 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 DebouncedDataTypeCondition for a sample data type, whose value represents an instantaneous value, e.g. instantaneous heart rate, instantaneous speed.

Parameters
@NonNull D dataType

a delta data type that is associated with SampleDataPoints, and whose value represents an instantaneous value

@NonNull T threshold

the threshold for the value of this data type to cross in order to satisfy the condition

@NonNull 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-alpha04
public final @NonNull ComparisonType getComparisonType()

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

getDataType

Added in 1.1.0-alpha04
public final @NonNullgetDataType()

DataType which this condition applies to.

getDurationAtThresholdSeconds

Added in 1.1.0-alpha04
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-alpha04
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-alpha04
public final @NonNullgetThreshold()

The threshold at which point this condition should be met.

hashCode

public int hashCode()

toString

public @NonNull String toString()