Class KiiClause


  • public class KiiClause
    extends java.lang.Object
    Provide apis to construct query condition.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  KiiClause.FieldType
      This enum represents supported field type for hasFieldClause.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static KiiClause and​(KiiClause... clauses)
      Concatenate KiiClause with AND operator.
      static KiiClause equals​(java.lang.String key, boolean value)
      Create a clause of equals condition.
      static KiiClause equals​(java.lang.String key, double value)
      Create a clause of equals condition.
      static KiiClause equals​(java.lang.String key, int value)
      Create a clause of equals condition.
      static KiiClause equals​(java.lang.String key, long value)
      Create a clause of equals condition.
      static KiiClause equals​(java.lang.String key, java.lang.Object value)
      Create a clause of equals condition.
      static KiiClause equals​(java.lang.String key, java.lang.String value)
      Create a clause of equals condition.
      static KiiClause geoBox​(java.lang.String key, GeoPoint northEast, GeoPoint southWest)
      Create a clause of geo box.
      static KiiClause geoDistance​(java.lang.String key, GeoPoint center, double radius, java.lang.String calculatedDistance)
      Create a clause of geo distance.
      static KiiClause greaterThan​(java.lang.String key, double value)
      Create a clause of greater than.
      static KiiClause greaterThan​(java.lang.String key, int value)
      Create a clause of greater than.
      static KiiClause greaterThan​(java.lang.String key, long value)
      Create a clause of greater than.
      static KiiClause greaterThan​(java.lang.String key, java.lang.Object value)
      Create a clause of greater than.
      static KiiClause greaterThan​(java.lang.String key, java.lang.String value)
      Create a clause of greater than.
      static KiiClause greaterThanOrEqual​(java.lang.String key, double value)
      Create a clause of greater than or equal.
      static KiiClause greaterThanOrEqual​(java.lang.String key, int value)
      Create a clause of greater than or equal.
      static KiiClause greaterThanOrEqual​(java.lang.String key, long value)
      Create a clause of greater than or equal.
      static KiiClause greaterThanOrEqual​(java.lang.String key, java.lang.Object value)
      Create a clause of greater than or equal.
      static KiiClause greaterThanOrEqual​(java.lang.String key, java.lang.String value)
      Create a clause of greater than or equal.
      static KiiClause hasField​(java.lang.String key, KiiClause.FieldType fieldType)
      Create a clause to return all entities that have a specified field.
      static KiiClause inWithDoubleValue​(java.lang.String key, double... value)
      Create a clause of in condition.
      static KiiClause inWithIntValue​(java.lang.String key, int... value)
      Create a clause of in condition.
      static KiiClause inWithLongValue​(java.lang.String key, long... value)
      Create a clause of in condition.
      static KiiClause inWithStringValue​(java.lang.String key, java.lang.String... value)
      Create a clause of in condition.
      static KiiClause lessThan​(java.lang.String key, double value)
      Create a clause of the less than
      static KiiClause lessThan​(java.lang.String key, int value)
      Create a clause of the less than
      static KiiClause lessThan​(java.lang.String key, long value)
      Create a clause of the less than
      static KiiClause lessThan​(java.lang.String key, java.lang.Object value)
      Create a clause of the less than
      static KiiClause lessThan​(java.lang.String key, java.lang.String value)
      Create a clause of the less than
      static KiiClause lessThanOrEqual​(java.lang.String key, double value)
      Create a clause of the less than or equal
      static KiiClause lessThanOrEqual​(java.lang.String key, int value)
      Create a clause of the less than or equal
      static KiiClause lessThanOrEqual​(java.lang.String key, long value)
      Create a clause of the less than or equal
      static KiiClause lessThanOrEqual​(java.lang.String key, java.lang.Object value)
      Create a clause of less than or equal.
      static KiiClause lessThanOrEqual​(java.lang.String key, java.lang.String value)
      Create a clause of the less than or equal
      static KiiClause not​(KiiClause clause)
      Concatenate KiiClause with NOT operator.
      static KiiClause notEquals​(java.lang.String key, boolean value)
      Create a clause of not equals condition.
      static KiiClause notEquals​(java.lang.String key, double value)
      Create a clause of not equals condition.
      static KiiClause notEquals​(java.lang.String key, int value)
      Create a clause of not equals condition.
      static KiiClause notEquals​(java.lang.String key, long value)
      Create a clause of not equals condition.
      static KiiClause notEquals​(java.lang.String key, java.lang.Object value)
      Create a clause of not equals condition.
      static KiiClause notEquals​(java.lang.String key, java.lang.String value)
      Create a clause of not equals condition.
      static KiiClause or​(KiiClause... clauses)
      Concatenate KiiClause with OR operator.
      static KiiClause startsWith​(java.lang.String key, java.lang.String value)
      Create a clause with the prefix condition.It matches the
      specified key's value to be starts with the specified value.
      • Methods inherited from class java.lang.Object

        clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • equals

        @NonNull
        public static KiiClause equals​(@NonNull
                                       java.lang.String key,
                                       int value)
        Create a clause of equals condition.
        Parameters:
        key - target of comparison.
        value - to be compared.
        Returns:
        KiiClause instance.
      • equals

        @NonNull
        public static KiiClause equals​(@NonNull
                                       java.lang.String key,
                                       long value)
        Create a clause of equals condition.
        Parameters:
        key - target of comparison.
        value - to be compared.
        Returns:
        KiiClause instance.
      • equals

        @NonNull
        public static KiiClause equals​(@NonNull
                                       java.lang.String key,
                                       double value)
        Create a clause of equals condition.
        Parameters:
        key - target of comparison.
        value - to be compared.
        Returns:
        KiiClause instance.
      • equals

        @NonNull
        public static KiiClause equals​(@NonNull
                                       java.lang.String key,
                                       boolean value)
        Create a clause of equals condition.
        Parameters:
        key - target of comparison.
        value - to be compared.
        Returns:
        KiiClause instance.
      • equals

        @NonNull
        public static KiiClause equals​(@NonNull
                                       java.lang.String key,
                                       @NonNull
                                       java.lang.String value)
        Create a clause of equals condition.
        Parameters:
        key - target of comparison.
        value - to be compared.
        Returns:
        KiiClause instance.
      • equals

        @NonNull
        public static KiiClause equals​(@NonNull
                                       java.lang.String key,
                                       @NonNull
                                       java.lang.Object value)
        Create a clause of equals condition.
        Parameters:
        key - target of comparison.
        value - to be compared. must be a instance of Integer, Long, Double, Boolean, String.
        Returns:
        KiiClause instance.
      • notEquals

        @NonNull
        public static KiiClause notEquals​(@NonNull
                                          java.lang.String key,
                                          int value)
        Create a clause of not equals condition.
        Parameters:
        key - target of comparison.
        value - to be compared.
        Returns:
        KiiClause instance.
      • notEquals

        @NonNull
        public static KiiClause notEquals​(@NonNull
                                          java.lang.String key,
                                          long value)
        Create a clause of not equals condition.
        Parameters:
        key - target of comparison.
        value - to be compared.
        Returns:
        KiiClause instance.
      • notEquals

        @NonNull
        public static KiiClause notEquals​(@NonNull
                                          java.lang.String key,
                                          double value)
        Create a clause of not equals condition.
        Parameters:
        key - target of comparison.
        value - to be compared.
        Returns:
        KiiClause instance.
      • notEquals

        @NonNull
        public static KiiClause notEquals​(@NonNull
                                          java.lang.String key,
                                          boolean value)
        Create a clause of not equals condition.
        Parameters:
        key - target of comparison.
        value - to be compared.
        Returns:
        KiiClause instance.
      • notEquals

        @NonNull
        public static KiiClause notEquals​(@NonNull
                                          java.lang.String key,
                                          @NonNull
                                          java.lang.String value)
        Create a clause of not equals condition.
        Parameters:
        key - target of comparison.
        value - to be compared.
        Returns:
        KiiClause instance.
      • notEquals

        @NonNull
        public static KiiClause notEquals​(@NonNull
                                          java.lang.String key,
                                          @NonNull
                                          java.lang.Object value)
        Create a clause of not equals condition.
        Parameters:
        key - target of comparison.
        value - to be compared. must be a instance of Integer, Long, Double, Boolean, String.
        Returns:
        KiiClause instance.
      • or

        @NonNull
        public static KiiClause or​(@NonNull
                                   KiiClause... clauses)
        Concatenate KiiClause with OR operator. Query performance will be worse as the number of objects in bucket increases, so we recommend you avoid the OR clause if possible.
        Parameters:
        clauses - to be concatenated with OR operator.
        Returns:
        Instance of concatenated KiiClause. If only one clause is provided, returns given clause.
        Throws:
        java.lang.IllegalArgumentException - Thrown if the provided clause is null or 0 length.
      • and

        @NonNull
        public static KiiClause and​(@NonNull
                                    KiiClause... clauses)
        Concatenate KiiClause with AND operator.
        Parameters:
        clauses - to be concatenated with OR operator.
        Returns:
        Instance of concatenated KiiClause. If only one clause is provided, returns given clause.
        Throws:
        java.lang.IllegalArgumentException - Thrown if the provided clause is null or 0 length.
      • not

        @NonNull
        public static KiiClause not​(@NonNull
                                    KiiClause clause)
        Concatenate KiiClause with NOT operator. Query performance will be worse as the number of objects in bucket increases, so we recommend you avoid the NOT clause if possible.
        Parameters:
        clause - to be concatenated with NOT operator.
        Returns:
        Instance of concatenated KiiClause.
        Throws:
        java.lang.IllegalArgumentException - Thrown if the provided clause is null.
      • inWithIntValue

        @NonNull
        public static KiiClause inWithIntValue​(@NonNull
                                               java.lang.String key,
                                               @NonNull
                                               int... value)
        Create a clause of in condition. Query records matches with key-value specified by argument.
        More efficient than using combination of "equals" and "or" When querying the multiple records with specific key.
        Parameters:
        key - target of comparison.
        value - to be compared. Value can not be empty and maximum allowed value length is 200.
        Returns:
        KiiClause instance.
        Throws:
        java.lang.IllegalArgumentException - Thrown if the value is null, empty or exceeds maximum length.
      • inWithLongValue

        @NonNull
        public static KiiClause inWithLongValue​(@NonNull
                                                java.lang.String key,
                                                @NonNull
                                                long... value)
        Create a clause of in condition. Query records matches with key-value specified by argument.
        More efficient than using combination of "equals" and "or" When querying the multiple records with specific key.
        Parameters:
        key - target of comparison.
        value - to be compared. Value can not be empty and maximum allowed value length is 200.
        Throws:
        java.lang.IllegalArgumentException - Thrown if the value is null, empty or exceeds maximum length.
      • inWithDoubleValue

        @NonNull
        public static KiiClause inWithDoubleValue​(@NonNull
                                                  java.lang.String key,
                                                  @NonNull
                                                  double... value)
        Create a clause of in condition. Query records matches with key-value specified by argument.
        More efficient than using combination of "equals" and "or" When querying the multiple records with specific key.
        Parameters:
        key - target of comparison.
        value - to be compared. Value can not be empty and maximum allowed value length is 200.
        Returns:
        KiiClause instance.
        Throws:
        java.lang.IllegalArgumentException - Thrown if the value is null, empty or exceeds maximum length.
      • inWithStringValue

        @NonNull
        public static KiiClause inWithStringValue​(@NonNull
                                                  java.lang.String key,
                                                  @NonNull
                                                  java.lang.String... value)
        Create a clause of in condition. Query records matches with key-value specified by argument.
        More efficient than using combination of "equals" and "or" When querying the multiple records with specific key.
        Parameters:
        key - target of comparison.
        value - to be compared. Value can not be empty and maximum allowed value length is 200.
        Returns:
        KiiClause instance.
        Throws:
        java.lang.IllegalArgumentException - Thrown if the value is null, empty or exceeds maximum length.
      • greaterThan

        @NonNull
        public static KiiClause greaterThan​(@NonNull
                                            java.lang.String key,
                                            @NonNull
                                            java.lang.Object value)
        Create a clause of greater than.
        Parameters:
        key - target of comparison
        value - to be compared. must be a instance of Integer, Long, Double, String.
        Returns:
        KiiClause instance.
      • greaterThan

        @NonNull
        public static KiiClause greaterThan​(@NonNull
                                            java.lang.String key,
                                            int value)
        Create a clause of greater than.
        Parameters:
        key - target of comparison
        value - to be compared.
        Returns:
        KiiClause instance.
      • greaterThan

        @NonNull
        public static KiiClause greaterThan​(@NonNull
                                            java.lang.String key,
                                            long value)
        Create a clause of greater than.
        Parameters:
        key - target of comparison
        value - to be compared.
        Returns:
        KiiClause instance.
      • greaterThan

        @NonNull
        public static KiiClause greaterThan​(@NonNull
                                            java.lang.String key,
                                            double value)
        Create a clause of greater than.
        Parameters:
        key - target of comparison
        value - to be compared.
        Returns:
        KiiClause instance.
      • greaterThan

        @NonNull
        public static KiiClause greaterThan​(@NonNull
                                            java.lang.String key,
                                            @NonNull
                                            java.lang.String value)
        Create a clause of greater than.
        Parameters:
        key - target of comparison
        value - to be compared.
        Returns:
        KiiClause instance.
      • greaterThanOrEqual

        @NonNull
        public static KiiClause greaterThanOrEqual​(@NonNull
                                                   java.lang.String key,
                                                   @NonNull
                                                   java.lang.Object value)
        Create a clause of greater than or equal.
        Parameters:
        key - target of comparison
        value - to be compared. must be a instance of Integer, Long, Double, String.
        Returns:
        KiiClause instance.
      • greaterThanOrEqual

        @NonNull
        public static KiiClause greaterThanOrEqual​(@NonNull
                                                   java.lang.String key,
                                                   int value)
        Create a clause of greater than or equal.
        Parameters:
        key - target of comparison
        value - to be compared.
        Returns:
        KiiClause instance.
      • greaterThanOrEqual

        @NonNull
        public static KiiClause greaterThanOrEqual​(@NonNull
                                                   java.lang.String key,
                                                   long value)
        Create a clause of greater than or equal.
        Parameters:
        key - target of comparison
        value - to be compared.
        Returns:
        KiiClause instance.
      • greaterThanOrEqual

        @NonNull
        public static KiiClause greaterThanOrEqual​(@NonNull
                                                   java.lang.String key,
                                                   double value)
        Create a clause of greater than or equal.
        Parameters:
        key - target of comparison
        value - to be compared.
        Returns:
        KiiClause instance.
      • greaterThanOrEqual

        @NonNull
        public static KiiClause greaterThanOrEqual​(@NonNull
                                                   java.lang.String key,
                                                   @NonNull
                                                   java.lang.String value)
        Create a clause of greater than or equal.
        Parameters:
        key - target of comparison
        value - to be compared.
        Returns:
        KiiClause instance.
      • lessThan

        @NonNull
        public static KiiClause lessThan​(@NonNull
                                         java.lang.String key,
                                         @NonNull
                                         java.lang.Object value)
        Create a clause of the less than
        Parameters:
        key - target of comparison
        value - to be compared. must be a instance of Integer, Long, Double, String.
        Returns:
        KiiClause instance.
      • lessThan

        @NonNull
        public static KiiClause lessThan​(@NonNull
                                         java.lang.String key,
                                         int value)
        Create a clause of the less than
        Parameters:
        key - target of comparison
        value - to be compared.
        Returns:
        KiiClause instance.
      • lessThan

        @NonNull
        public static KiiClause lessThan​(@NonNull
                                         java.lang.String key,
                                         long value)
        Create a clause of the less than
        Parameters:
        key - target of comparison
        value - to be compared.
        Returns:
        KiiClause instance.
      • lessThan

        @NonNull
        public static KiiClause lessThan​(@NonNull
                                         java.lang.String key,
                                         double value)
        Create a clause of the less than
        Parameters:
        key - target of comparison
        value - to be compared.
        Returns:
        KiiClause instance.
      • lessThan

        @NonNull
        public static KiiClause lessThan​(@NonNull
                                         java.lang.String key,
                                         @NonNull
                                         java.lang.String value)
        Create a clause of the less than
        Parameters:
        key - target of comparison
        value - to be compared.
        Returns:
        KiiClause instance.
      • lessThanOrEqual

        @NonNull
        public static KiiClause lessThanOrEqual​(@NonNull
                                                java.lang.String key,
                                                @NonNull
                                                java.lang.Object value)
        Create a clause of less than or equal.
        Parameters:
        key - target of comparison
        value - to be compared. must be a instance of Integer, Long, Double, String.
        Returns:
        KiiClause instance.
      • lessThanOrEqual

        @NonNull
        public static KiiClause lessThanOrEqual​(@NonNull
                                                java.lang.String key,
                                                int value)
        Create a clause of the less than or equal
        Parameters:
        key - target of comparison
        value - to be compared.
        Returns:
        KiiClause instance.
      • lessThanOrEqual

        @NonNull
        public static KiiClause lessThanOrEqual​(@NonNull
                                                java.lang.String key,
                                                long value)
        Create a clause of the less than or equal
        Parameters:
        key - target of comparison
        value - to be compared.
        Returns:
        KiiClause instance.
      • lessThanOrEqual

        @NonNull
        public static KiiClause lessThanOrEqual​(@NonNull
                                                java.lang.String key,
                                                double value)
        Create a clause of the less than or equal
        Parameters:
        key - target of comparison
        value - to be compared.
        Returns:
        KiiClause instance.
      • lessThanOrEqual

        @NonNull
        public static KiiClause lessThanOrEqual​(@NonNull
                                                java.lang.String key,
                                                @NonNull
                                                java.lang.String value)
        Create a clause of the less than or equal
        Parameters:
        key - target of comparison
        value - to be compared.
        Returns:
        KiiClause instance.
      • startsWith

        @NonNull
        public static KiiClause startsWith​(@NonNull
                                           java.lang.String key,
                                           @NonNull
                                           java.lang.String value)
        Create a clause with the prefix condition.It matches the
        specified key's value to be starts with the specified value.
        Parameters:
        key - target of comparison
        value - to be compared.
        Returns:
        KiiClause instance.
      • geoBox

        @NonNull
        public static KiiClause geoBox​(@NonNull
                                       java.lang.String key,
                                       @NonNull
                                       GeoPoint northEast,
                                       @NonNull
                                       GeoPoint southWest)
        Create a clause of geo box. This clause inquires objects in the specified rectangle. Rectangle would be placed parallel to the equator with specified coordinates of the corner.
        Parameters:
        key - name of the key to inquire, which holds geo point.
        northEast - north-east corner of the rectangle.
        southWest - south-west corner of the rectangle.
        Returns:
        KiiClause instance.
        Throws:
        java.lang.IllegalArgumentException - Thrown for following reasons :
      • specified key is null or empty.
      • specified northEast or southWest point is null.
      • geoDistance

        @NonNull
        public static KiiClause geoDistance​(@NonNull
                                            java.lang.String key,
                                            @NonNull
                                            GeoPoint center,
                                            double radius,
                                            @Nullable
                                            java.lang.String calculatedDistance)
        Create a clause of geo distance. This clause inquires objects in the specified circle.
        Parameters:
        key - name of the key to inquire, which holds geo point.
        center - geo point which specifies center of the circle.
        radius - of the circle. unit is meter.Valid range is ]0-20000000].
        calculatedDistance - use for retrieve distance from the center from the query result. If the specified value is null, query result will not contain the distance. Valid pattern for this param is ^[a-zA-Z_][a-zA-Z0-9_]*$. Note: You can get the results in ascending order of distances from center. To do so, build the orderBy field by "_calculated.{specified value of calculatedDistance}" and pass it in KiiQuery.sortByAsc(String). Note that, descending order of distances is not supported. The unit of distance is meter.
         String calculatedDistance = "distanceFromCurrentLoc"
         GeoPoint currentLoc = getCurrentUserLocation();
         KiiClause geoDist = KiiClause.geoDistance("location", currentLoc, 50, calculatedDistance);
         KiiQuery q = new KiiQuery(geoDist);
          // Sort by distances by ascending order.(Optional, use only if you intend 
         to retrieve the distances in a ascending order).
         String orderByKey = "_calculated."+ calculatedDistance;
         q.sortByAsc(orderByKey);
         KiiQueryResult res = Kii.bucket("myBucket).query(q);
         List list = res.getResult();
         KiiObject obj = list.get(0); // Check first element for example. 
         JSONObject calculated = obj.get("_calculated");
         double distanceInMeter = calculated.get(calculatedDistance);
         
        Returns:
        KiiClause instance.
        Throws:
        java.lang.IllegalArgumentException - Thrown for following reasons :
      • Specified key is null or empty.
      • Specified radius/calculatedDistance is invalid or center is null.
      • hasField

        @NonNull
        public static KiiClause hasField​(@NonNull
                                         java.lang.String key,
                                         @NonNull
                                         KiiClause.FieldType fieldType)
        Create a clause to return all entities that have a specified field.
        Parameters:
        key - name of the specified field.
        fieldType - The type of the content of the field.
        Returns:
        KiiClause instance.