com.samsung.android.sdk.healthdata
Class HealthDataResolver.Filter
- java.lang.Object
-
- com.samsung.android.sdk.healthdata.HealthDataResolver.Filter
-
- All Implemented Interfaces:
- Parcelable
- Enclosing class:
- HealthDataResolver
public abstract static class HealthDataResolver.Filter extends Object implements Parcelable
This class creates a filter to make the request range clear.
It can be used with the following requests.HealthDataResolver.ReadRequest
HealthDataResolver.UpdateRequest
HealthDataResolver.DeleteRequest
HealthDataResolver.AggregateRequest
Filter Examples
The multiple filters can be combined withand()
andor()
.If there are 3 filters:
Filter filter1 = Filter.eq("property1", "AAA"); Filter filter2 = Filter.eq("property2", "BBB"); Filter filter3 = Filter.greaterThanEquals("property3",100);
Case 1: and()
// Good example Filter goodFilterEx = Filter.and(filter1, filter2, filter3); // Bad example Filter badFilterEx = Filter.and(Filter.and(filter1, filter2), filter3);
Case 2: or()
// Good example Filter goodFilterEx = Filter.in("Property1", {"AAA", "BBB", "CCC"}); // Bad example Filter badFilterEx = Filter.or( Filter.eq("Property1", "AAA"), Filter.eq("Property2", "BBB"), Filter.eq("Property1", "CCC"));
Case 3: and(), or()
Filter filter = Filter.and(Filter.or(filter1, filter2), filter3);
- Since:
- 1.0.0
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static HealthDataResolver.Filter
and(HealthDataResolver.Filter filter, HealthDataResolver.Filter... additionalFilters)
Returns a logical expression filter combined with theAND
operator.static <T> HealthDataResolver.Filter
eq(String property, T value)
Returns a filter which checks if a given property of health data is equal to a value.static <T extends Comparable<T>>
HealthDataResolver.FiltergreaterThan(String property, T value)
Returns a filter which checks if a value of a given property is greater than a given value.static <T extends Comparable<T>>
HealthDataResolver.FiltergreaterThanEquals(String property, T value)
Returns a filter which checks if the value of a given property is greater than or equal to a given value.static <T> HealthDataResolver.Filter
in(String property, T[] values)
Returns a filter to check if given values for a given property are included in health data.static <T extends Comparable<T>>
HealthDataResolver.FilterlessThan(String property, T value)
Returns a filter which checks if a value of a given property is less than a given value.static <T extends Comparable<T>>
HealthDataResolver.FilterlessThanEquals(String property, T value)
Returns a filter which checks if a value of a given property is less than or equal to a given value.static HealthDataResolver.Filter
not(HealthDataResolver.Filter filter)
Returns a negation filter of a given filter.static HealthDataResolver.Filter
or(HealthDataResolver.Filter filter, HealthDataResolver.Filter... additionalFilters)
Returns a logical expression filter combined with theOR
operator.
-
-
-
Method Detail
-
and
public static HealthDataResolver.Filter and(HealthDataResolver.Filter filter, HealthDataResolver.Filter... additionalFilters)
Returns a logical expression filter combined with theAND
operator.- Parameters:
filter
- The filter object to combineadditionalFilters
- The additional filter objects to combine- Returns:
- The filter object that combines filters with
AND
- Throws:
IllegalArgumentException
- If filter contains invalid instance type ornull
- Since:
- 1.0.0
-
or
public static HealthDataResolver.Filter or(HealthDataResolver.Filter filter, HealthDataResolver.Filter... additionalFilters)
Returns a logical expression filter combined with theOR
operator.- Parameters:
filter
- The filter object to combineadditionalFilters
- The additional filter objects to combine- Returns:
- The filter object that combines filters with
OR
- Throws:
IllegalArgumentException
- If filter contains invalid instance type ornull
- Since:
- 1.0.0
-
not
public static HealthDataResolver.Filter not(HealthDataResolver.Filter filter)
Returns a negation filter of a given filter.- Parameters:
filter
- The filter object in negation- Returns:
- The negation filter object of the
filter
- Throws:
IllegalArgumentException
- If filter contains invalid instance type ornull
- Since:
- 1.0.0
-
eq
public static <T> HealthDataResolver.Filter eq(String property, T value)
Returns a filter which checks if a given property of health data is equal to a value.- Parameters:
property
- The property name of health datavalue
- The givenproperty
's value to check if it is equal. The value can be a number, string, ornull
.- Returns:
- The filter object that checks if the given property of health data is equal to the
value
- Throws:
IllegalArgumentException
- If theproperty
isnull
or if thevalue
is not a number, string, ornull
- Since:
- 1.0.0
-
lessThan
public static <T extends Comparable<T>> HealthDataResolver.Filter lessThan(String property, T value)
Returns a filter which checks if a value of a given property is less than a given value.- Parameters:
property
- The property name of health datavalue
- The specified value as number- Returns:
- The filter object that checks
- Throws:
IllegalArgumentException
- If the property or value isnull
or the value is not number- Since:
- 1.0.0
-
lessThanEquals
public static <T extends Comparable<T>> HealthDataResolver.Filter lessThanEquals(String property, T value)
Returns a filter which checks if a value of a given property is less than or equal to a given value.- Parameters:
property
- The property name of health datavalue
- The specified value as number- Returns:
- The filter object that
- Throws:
IllegalArgumentException
- If the property or value isnull
or the value is notNumber
object- Since:
- 1.0.0
-
greaterThan
public static <T extends Comparable<T>> HealthDataResolver.Filter greaterThan(String property, T value)
Returns a filter which checks if a value of a given property is greater than a given value.- Parameters:
property
- The property name of health datavalue
- The specified value as number- Returns:
- The filter object that
- Throws:
IllegalArgumentException
- If the property or value isnull
or the value is notNumber
object- Since:
- 1.0.0
-
greaterThanEquals
public static <T extends Comparable<T>> HealthDataResolver.Filter greaterThanEquals(String property, T value)
Returns a filter which checks if the value of a given property is greater than or equal to a given value.- Parameters:
property
- The property name of health datavalue
- The specified value as number- Returns:
- The filter object that
- Throws:
IllegalArgumentException
- If the property or value isnull
or the value is notNumber
object- Since:
- 1.0.0
-
in
public static <T> HealthDataResolver.Filter in(String property, T[] values)
Returns a filter to check if given values for a given property are included in health data.- Parameters:
property
- The property name of health datavalues
- The list of string orNumber
typed values- Returns:
- filter The filter object that
- Throws:
IllegalArgumentException
- Thrown if either of the following conditions has occurred:- the
property
isnull
or empty string values
isnull
or empty listvalues
has a different type with string or number
- the
- Since:
- 1.0.0
-
-