com.samsung.android.sdk.healthdata

Class 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.

    Filter Examples

    The multiple filters can be combined with and() and or().

    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()

    The filter of the figure above can be created as:

       // Good example
       Filter goodFilterEx = Filter.and(filter1, filter2, filter3);
      
       // Bad example
       Filter badFilterEx = Filter.and(Filter.and(filter1, filter2), filter3);

    Case 2: or()

    The filter of the figure above can be created as:

       // 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()

    The filter of the figure above can be created as:

       Filter filter = Filter.and(Filter.or(filter1, filter2), filter3);

    Since:
    1.0.0
    • Method Detail

      • 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 data
        value - The given property's value to check if it is equal. The value can be a number, string, or null.
        Returns:
        The filter object that checks if the given property of health data is equal to the value
        Throws:
        IllegalArgumentException - If the property is null or if the value is not a number, string, or null
        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 data
        value - The specified value as number
        Returns:
        The filter object that checks
        Throws:
        IllegalArgumentException - If the property or value is null 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 data
        value - The specified value as number
        Returns:
        The filter object that
        Throws:
        IllegalArgumentException - If the property or value is null or the value is not Number 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 data
        value - The specified value as number
        Returns:
        The filter object that
        Throws:
        IllegalArgumentException - If the property or value is null or the value is not Number 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 data
        value - The specified value as number
        Returns:
        The filter object that
        Throws:
        IllegalArgumentException - If the property or value is null or the value is not Number 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 data
        values - The list of string or Number typed values
        Returns:
        filter The filter object that
        Throws:
        IllegalArgumentException - Thrown if either of the following conditions has occurred:
        • the property is null or empty string
        • values is null or empty list
        • values has a different type with string or number
        Since:
        1.0.0