com.samsung.android.sdk.healthdata
Class HealthDataResolver.AggregateRequest.Builder
- java.lang.Object
-
- com.samsung.android.sdk.healthdata.HealthDataResolver.AggregateRequest.Builder
-
- Enclosing interface:
- HealthDataResolver.AggregateRequest
public static class HealthDataResolver.AggregateRequest.Builder extends Object
This class creates anHealthDataResolver.AggregateRequest
's instance for the specified data type.- Since:
- 1.0.0
-
-
Constructor Summary
Constructors Constructor and Description Builder()
Helps to construct aHealthDataResolver.AggregateRequest
object.
-
Method Summary
-
-
-
Constructor Detail
-
Builder
public Builder()
Helps to construct aHealthDataResolver.AggregateRequest
object.- Since:
- 1.0.0
-
-
Method Detail
-
setDataType
public HealthDataResolver.AggregateRequest.Builder setDataType(String type)
Sets a health data type for the aggregate request. It has to be specified before callingbuild()
.- Parameters:
type
-HEALTH_DATA_TYPE
of data type- Returns:
- The object that applies the data type
- Since:
- 1.0.0
-
setFilter
public HealthDataResolver.AggregateRequest.Builder setFilter(HealthDataResolver.Filter filter)
Sets a filter for the aggregate request.- Parameters:
filter
- The filter object- Returns:
- The object that applies the filter
- Since:
- 1.0.0
-
setPackageName
public HealthDataResolver.AggregateRequest.Builder setPackageName(String packageName)
Sets the package name that provides health data for the aggregate request.- Parameters:
packageName
- the package name- Returns:
- The object that applies the package name
- Since:
- 1.0.0
-
setSourceDevices
public HealthDataResolver.AggregateRequest.Builder setSourceDevices(List<String> uuidList)
Sets a UUID list for source devices for the aggregate request.- Parameters:
uuidList
- The UUID list for source devices- Returns:
- The object that applies source devices
- Since:
- 1.0.0
-
setTimeGroup
public HealthDataResolver.AggregateRequest.Builder setTimeGroup(HealthDataResolver.AggregateRequest.TimeGroupUnit unit, int amount, String timeProperty, String alias)
Sets a group withHealthDataResolver.AggregateRequest.TimeGroupUnit
for the aggregate request. It makes its result contain grouped values by the specified time unit. Refer to the related example.- Parameters:
unit
- The time group unitamount
- The amount for grouping by the time group unit.
-
If you set a
- Time group unit:
HealthDataResolver.AggregateRequest.TimeGroupUnit.HOURLY
- Amount: 8
- Time range: 00:00 ~ 09:00 of today
HealthDataResolver.AggregateRequest.TimeGroupUnit.MINUTELY
- 1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 30, 60HealthDataResolver.AggregateRequest.TimeGroupUnit.HOURLY
- 1, 2, 3, 4, 6, 8, 12, 24HealthDataResolver.AggregateRequest.TimeGroupUnit.DAILY
- 1HealthDataResolver.AggregateRequest.TimeGroupUnit.WEEKLY
- 1HealthDataResolver.AggregateRequest.TimeGroupUnit.MONTHLY
- 1, 3, 6
HealthDataResolver.AggregateRequest.Builder
object with following configuration,The amount value for each time group unit is defined in advance. Be mindful to use only the values below.
- Time group unit:
timeProperty
- The time property name that its values are grouped in the resultalias
- The alias for the time property to check the result- Returns:
- The object that applies the time group
- Since:
- 1.0.0
-
setTimeGroup
public HealthDataResolver.AggregateRequest.Builder setTimeGroup(HealthDataResolver.AggregateRequest.TimeGroupUnit unit, int amount, String timeProperty, String offsetProperty, String alias)
Sets a group withHealthDataResolver.AggregateRequest.TimeGroupUnit
and the time offset for the aggregate request. It makes its result contain grouped values by the specified time unit. Refer to the related example.- Parameters:
unit
- The time group unitamount
- The amount for grouping by the time group unit.
-
If you set a
- Time group unit:
HealthDataResolver.AggregateRequest.TimeGroupUnit.HOURLY
- Amount: 8
- Time range: 00:00 ~ 09:00 of today
HealthDataResolver.AggregateRequest.TimeGroupUnit.MINUTELY
- 1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 30, 60HealthDataResolver.AggregateRequest.TimeGroupUnit.HOURLY
- 1, 2, 3, 4, 6, 8, 12, 24HealthDataResolver.AggregateRequest.TimeGroupUnit.DAILY
- 1HealthDataResolver.AggregateRequest.TimeGroupUnit.WEEKLY
- 1HealthDataResolver.AggregateRequest.TimeGroupUnit.MONTHLY
- 1, 3, 6
HealthDataResolver.AggregateRequest.Builder
object with following configuration,The amount value for each time group unit is defined in advance. Be mindful to use only the values below.
- Time group unit:
timeProperty
- The time property name that its values are grouped in the resultoffsetProperty
- The time offset property which represents the time offset for the target time propertyalias
- The alias for the time property to check the result- Returns:
- The object that applies the time group
- Since:
- 1.0.0
-
addGroup
public HealthDataResolver.AggregateRequest.Builder addGroup(String property, String alias)
Adds a group with a property name for the aggregate request.- Parameters:
property
- The property to get grouped values in the aggregate resultalias
- The alias for the property to check the result- Returns:
- The object that applies the property name
- Since:
- 1.0.0
-
addFunction
public HealthDataResolver.AggregateRequest.Builder addFunction(HealthDataResolver.AggregateRequest.AggregateFunction aggregate, String property, String alias)
Adds a required aggregation function. It has to be specified before callingbuild()
.- Parameters:
aggregate
- The aggregate functionproperty
- The property name for the aggregate function. In case ofCOUNT
, "*" is allowed.alias
- The alias for the property to check the result- Returns:
- The object that applies the aggregation function
- Since:
- 1.0.0
-
setSort
public HealthDataResolver.AggregateRequest.Builder setSort(String property, HealthDataResolver.SortOrder sortOrder)
Sets the sort order for a given property name or alias.- Parameters:
property
- The property name or alias to be sorted. If it'snull
, the result is not ordered.sortOrder
- The sort order. If it'snull
, the result is ordered with the default sort order.- Returns:
- The object that applies the sort order
- Since:
- 1.0.0
-
setLocalTimeRange
public HealthDataResolver.AggregateRequest.Builder setLocalTimeRange(String timeProperty, String offsetProperty, long begin, long end)
Sets the local time range not to miss data from the query's result when there exist data with a differentTIME_OFFSET
in the saved health data.
The data that has a different
TIME_OFFSET
with other data'sTIME_OFFSET
can be saved when the daylight time is applied or the user moves to another region by like a travel. Building a complete query to aggregate all data including the differentTIME_OFFSET
is not easy.
Use this API to build an aggregate request as possible.- Parameters:
timeProperty
- The time property name that needs to add a filteroffsetProperty
- The time offset propertybegin
- The beginning time withGMT+0
milliseconds.
E.g. If you would like to get data from00:00:00
on October 26th, 2021 in your region, set the value with1635206400000
.
See sample codes.
Its minimum value isLong.MIN_VALUE
.end
- The end time withGMT+0
milliseconds.
E.g. If you would like to get data until00:00:00
on October 26th, 2021 in your region, set the value with1635206400000
.
See sample codes.
Its maximum value isLong.MAX_VALUE
.- Returns:
- The object that applies the local time range
- Since:
- 1.3.0
-
build
public HealthDataResolver.AggregateRequest build()
Builds a newHealthDataResolver.AggregateRequest
object. Check if following information is specified.- Data type
- Aggregate function
- Returns:
- The
HealthDataResolver.AggregateRequest
object - Throws:
IllegalStateException
- If enough information is not specified- Since:
- 1.0.0
- See Also:
setDataType(String)
,addFunction(HealthDataResolver.AggregateRequest.AggregateFunction, String, String)
-
-