Class AggregateResult
java.lang.Object
com.codename1.health.AggregateResult
One bucket of an AggregateQuery result: a span of time and the
metrics computed over it.
A missing value is null, never zero
get(HealthDataType,AggregateMetric) returns null when the bucket
held no data. That distinction matters: a day with no step data and a
day on which the user genuinely took no steps are different facts, and
collapsing them into 0 turns "we don't know" into "you did nothing".
Every health app that gets this wrong draws the same wrong chart --
a flat line through the days the phone was left at home.
HealthQuantity total = bucket.get(HealthDataType.STEPS, AggregateMetric.TOTAL);
if (total == null) {
renderNoDataMarker(bucket.getBucketStartMillis());
} else {
renderBar(total.getValue(HealthUnit.COUNT));
}
-
Constructor Summary
ConstructorsConstructorDescriptionAggregateResult(long bucketStartMillis, long bucketEndMillis) Creates an empty bucket spanning[start, end). -
Method Summary
Modifier and TypeMethodDescriptionget(HealthDataType type, AggregateMetric metric) The computed value, ornullwhen this bucket held no data for that type and metric.longExclusive end of this bucket, epoch millis UTC.longInclusive start of this bucket, epoch millis UTC.intgetSampleCount(HealthDataType type) How many samples contributed totypein this bucket.booleanisEmpty()truewhen no metric in this bucket produced a value.voidput(HealthDataType type, AggregateMetric metric, HealthQuantity value) Records a computed value.voidsetSampleCount(HealthDataType type, int count) Records how many samples contributed totype.toString()Returns a string representation of the object.
-
Constructor Details
-
AggregateResult
public AggregateResult(long bucketStartMillis, long bucketEndMillis) Creates an empty bucket spanning[start, end).
-
-
Method Details
-
getBucketStartMillis
public long getBucketStartMillis()Inclusive start of this bucket, epoch millis UTC. -
getBucketEndMillis
public long getBucketEndMillis()Exclusive end of this bucket, epoch millis UTC. -
get
The computed value, ornullwhen this bucket held no data for that type and metric. See the class documentation -- do not substitute zero. -
getSampleCount
How many samples contributed totypein this bucket. Zero is a real answer here, unlikeget(HealthDataType,AggregateMetric). -
isEmpty
public boolean isEmpty()truewhen no metric in this bucket produced a value. -
put
Records a computed value. Called byHealthStoreand by ports; a null value clears the entry rather than storing a placeholder. -
setSampleCount
Records how many samples contributed totype. -
toString
Description copied from class:ObjectReturns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method. The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of: getClass().getName() + '@' + Integer.toHexString(hashCode())
-