DataPoint.Builder

public static class DataPoint.Builder extends Object

Builder for DataPoint instances.

Public Method Summary

DataPoint
build()
Builds and returns the DataPoint.
DataPoint.Builder
setActivityField(Field field, String activity)
Sets the value of an activity field to activity.
DataPoint.Builder
setField(Field field, float value)
Sets the floating point value of the given field to value.
DataPoint.Builder
setField(Field field, Map<StringFloat> value)
Sets the map value of the given field to value.
DataPoint.Builder
setField(Field field, int value)
Sets the integer value of the given field to value.
DataPoint.Builder
setField(Field field, String value)
Sets the string value of the given field to value.
DataPoint.Builder
setFloatValues(float... values)
Sets the values of the data point, where the format for all of its values is float.
DataPoint.Builder
setIntValues(int... values)
Sets the values of the data point, where the format for all of its values is int.
DataPoint.Builder
setTimeInterval(long startTime, long endTime, TimeUnit timeUnit)
Sets the time interval of a data point that represents an interval of time.
DataPoint.Builder
setTimestamp(long timestamp, TimeUnit timeUnit)
Sets the timestamp of a data point that represent an instantaneous reading, measurement, or input.

Inherited Method Summary

Public Methods

public DataPoint build ()

Builds and returns the DataPoint.

public DataPoint.Builder setActivityField (Field field, String activity)

Sets the value of an activity field to activity.

Throws
IllegalArgumentException If the given index is out of the range for this data type.
IllegalStateException If the field isn't of format Field.FORMAT_INT32.

public DataPoint.Builder setField (Field field, float value)

Sets the floating point value of the given field to value.

Throws
IllegalArgumentException If the given index is out of the range for this data type.
IllegalStateException If the field isn't of format Field.FORMAT_FLOAT.

public DataPoint.Builder setField (Field field, Map<StringFloat> value)

Sets the map value of the given field to value.

Throws
IllegalArgumentException If the given index is out of the range for this data type.
IllegalStateException If the field isn't of format Field.FORMAT_MAP.

public DataPoint.Builder setField (Field field, int value)

Sets the integer value of the given field to value.

Throws
IllegalArgumentException If the given index is out of the range for this data type.
IllegalStateException If the field isn't of format Field.FORMAT_INT32.

public DataPoint.Builder setField (Field field, String value)

Sets the string value of the given field to value.

Throws
IllegalArgumentException If the given index is out of the range for this data type.
IllegalStateException If the field isn't of format Field.FORMAT_STRING.

public DataPoint.Builder setFloatValues (float... values)

Sets the values of the data point, where the format for all of its values is float.

Parameters
values The value for each field of the data point, in order.

public DataPoint.Builder setIntValues (int... values)

Sets the values of the data point, where the format for all of its values is int.

Parameters
values The value for each field of the data point, in order.

public DataPoint.Builder setTimeInterval (long startTime, long endTime, TimeUnit timeUnit)

Sets the time interval of a data point that represents an interval of time. For data points that represent instantaneous readings, setTimestamp(long, TimeUnit) should be used.

Examples of data types that represent intervals include:

Google Fit accepts timestamps with up to nanosecond granularity.
Parameters
startTime The start time in the given unit, representing elapsed time since epoch.
endTime The end time in the given unit, representing elapsed time since epoch.
timeUnit The time unit of both start and end timestamps.

public DataPoint.Builder setTimestamp (long timestamp, TimeUnit timeUnit)

Sets the timestamp of a data point that represent an instantaneous reading, measurement, or input. For data points that represent intervals, setTimeInterval(long, long, TimeUnit) should be used.

Examples of data types with instantaneous timestamp include:

Google Fit accepts timestamps with up to nanosecond granularity for all DataTypes.
Parameters
timestamp The timestamp in the given unit, representing elapsed time since epoch.
timeUnit The unit of the given timestamp.