1616
1717package io .objectbox .query ;
1818
19- import java .io .Closeable ;
20- import java .util .ArrayList ;
21- import java .util .Comparator ;
22- import java .util .Date ;
23- import java .util .List ;
24-
25- import javax .annotation .Nullable ;
26-
2719import io .objectbox .Box ;
2820import io .objectbox .EntityInfo ;
2921import io .objectbox .Property ;
3022import io .objectbox .annotation .apihint .Internal ;
3123import io .objectbox .exception .DbException ;
3224import io .objectbox .relation .RelationInfo ;
3325
26+ import javax .annotation .Nullable ;
27+ import java .io .Closeable ;
28+ import java .util .ArrayList ;
29+ import java .util .Comparator ;
30+ import java .util .Date ;
31+ import java .util .List ;
32+
3433/**
3534 * Builds a {@link Query Query} using conditions which can then be used to return a list of matching Objects.
3635 * <p>
@@ -153,9 +152,9 @@ private native long nativeLink(long handle, long storeHandle, int relationOwnerE
153152
154153 private native long nativeNotEqual (long handle , int propertyId , long value );
155154
156- private native long nativeLess (long handle , int propertyId , long value );
155+ private native long nativeLess (long handle , int propertyId , long value , boolean withEqual );
157156
158- private native long nativeGreater (long handle , int propertyId , long value );
157+ private native long nativeGreater (long handle , int propertyId , long value , boolean withEqual );
159158
160159 private native long nativeBetween (long handle , int propertyId , long value1 , long value2 );
161160
@@ -175,27 +174,27 @@ private native long nativeLink(long handle, long storeHandle, int relationOwnerE
175174
176175 private native long nativeEndsWith (long handle , int propertyId , String value , boolean caseSensitive );
177176
178- private native long nativeLess (long handle , int propertyId , String value , boolean caseSensitive );
177+ private native long nativeLess (long handle , int propertyId , String value , boolean caseSensitive , boolean withEqual );
179178
180- private native long nativeGreater (long handle , int propertyId , String value , boolean caseSensitive );
179+ private native long nativeGreater (long handle , int propertyId , String value , boolean caseSensitive , boolean withEqual );
181180
182181 private native long nativeIn (long handle , int propertyId , String [] value , boolean caseSensitive );
183182
184183 // ------------------------------ FPs ------------------------------
185184
186- private native long nativeLess (long handle , int propertyId , double value );
185+ private native long nativeLess (long handle , int propertyId , double value , boolean withEqual );
187186
188- private native long nativeGreater (long handle , int propertyId , double value );
187+ private native long nativeGreater (long handle , int propertyId , double value , boolean withEqual );
189188
190189 private native long nativeBetween (long handle , int propertyId , double value1 , double value2 );
191190
192191 // ------------------------------ Bytes ------------------------------
193192
194193 private native long nativeEqual (long handle , int propertyId , byte [] value );
195194
196- private native long nativeLess (long handle , int propertyId , byte [] value );
195+ private native long nativeLess (long handle , int propertyId , byte [] value , boolean withEqual );
197196
198- private native long nativeGreater (long handle , int propertyId , byte [] value );
197+ private native long nativeGreater (long handle , int propertyId , byte [] value , boolean withEqual );
199198
200199 @ Internal
201200 public QueryBuilder (Box <T > box , long storeHandle , String entityName ) {
@@ -531,13 +530,25 @@ public QueryBuilder<T> notEqual(Property<T> property, long value) {
531530
532531 public QueryBuilder <T > less (Property <T > property , long value ) {
533532 verifyHandle ();
534- checkCombineCondition (nativeLess (handle , property .getId (), value ));
533+ checkCombineCondition (nativeLess (handle , property .getId (), value , false ));
534+ return this ;
535+ }
536+
537+ public QueryBuilder <T > lessOrEqual (Property <T > property , long value ) {
538+ verifyHandle ();
539+ checkCombineCondition (nativeLess (handle , property .getId (), value , true ));
535540 return this ;
536541 }
537542
538543 public QueryBuilder <T > greater (Property <T > property , long value ) {
539544 verifyHandle ();
540- checkCombineCondition (nativeGreater (handle , property .getId (), value ));
545+ checkCombineCondition (nativeGreater (handle , property .getId (), value , false ));
546+ return this ;
547+ }
548+
549+ public QueryBuilder <T > greaterOrEqual (Property <T > property , long value ) {
550+ verifyHandle ();
551+ checkCombineCondition (nativeGreater (handle , property .getId (), value , true ));
541552 return this ;
542553 }
543554
@@ -614,9 +625,21 @@ public QueryBuilder<T> notEqual(Property<T> property, Date value) {
614625 return this ;
615626 }
616627
628+ /**
629+ * @throws NullPointerException if given value is null. Use {@link #isNull(Property)} instead.
630+ */
617631 public QueryBuilder <T > less (Property <T > property , Date value ) {
618632 verifyHandle ();
619- checkCombineCondition (nativeLess (handle , property .getId (), value .getTime ()));
633+ checkCombineCondition (nativeLess (handle , property .getId (), value .getTime (), false ));
634+ return this ;
635+ }
636+
637+ /**
638+ * @throws NullPointerException if given value is null. Use {@link #isNull(Property)} instead.
639+ */
640+ public QueryBuilder <T > lessOrEqual (Property <T > property , Date value ) {
641+ verifyHandle ();
642+ checkCombineCondition (nativeLess (handle , property .getId (), value .getTime (), true ));
620643 return this ;
621644 }
622645
@@ -625,7 +648,16 @@ public QueryBuilder<T> less(Property<T> property, Date value) {
625648 */
626649 public QueryBuilder <T > greater (Property <T > property , Date value ) {
627650 verifyHandle ();
628- checkCombineCondition (nativeGreater (handle , property .getId (), value .getTime ()));
651+ checkCombineCondition (nativeGreater (handle , property .getId (), value .getTime (), false ));
652+ return this ;
653+ }
654+
655+ /**
656+ * @throws NullPointerException if given value is null. Use {@link #isNull(Property)} instead.
657+ */
658+ public QueryBuilder <T > greaterOrEqual (Property <T > property , Date value ) {
659+ verifyHandle ();
660+ checkCombineCondition (nativeGreater (handle , property .getId (), value .getTime (), true ));
629661 return this ;
630662 }
631663
@@ -766,7 +798,13 @@ public QueryBuilder<T> less(Property<T> property, String value) {
766798
767799 public QueryBuilder <T > less (Property <T > property , String value , StringOrder order ) {
768800 verifyHandle ();
769- checkCombineCondition (nativeLess (handle , property .getId (), value , order == StringOrder .CASE_SENSITIVE ));
801+ checkCombineCondition (nativeLess (handle , property .getId (), value , order == StringOrder .CASE_SENSITIVE , false ));
802+ return this ;
803+ }
804+
805+ public QueryBuilder <T > lessOrEqual (Property <T > property , String value , StringOrder order ) {
806+ verifyHandle ();
807+ checkCombineCondition (nativeLess (handle , property .getId (), value , order == StringOrder .CASE_SENSITIVE , true ));
770808 return this ;
771809 }
772810
@@ -780,7 +818,13 @@ public QueryBuilder<T> greater(Property<T> property, String value) {
780818
781819 public QueryBuilder <T > greater (Property <T > property , String value , StringOrder order ) {
782820 verifyHandle ();
783- checkCombineCondition (nativeGreater (handle , property .getId (), value , order == StringOrder .CASE_SENSITIVE ));
821+ checkCombineCondition (nativeGreater (handle , property .getId (), value , order == StringOrder .CASE_SENSITIVE , false ));
822+ return this ;
823+ }
824+
825+ public QueryBuilder <T > greaterOrEqual (Property <T > property , String value , StringOrder order ) {
826+ verifyHandle ();
827+ checkCombineCondition (nativeGreater (handle , property .getId (), value , order == StringOrder .CASE_SENSITIVE , true ));
784828 return this ;
785829 }
786830
@@ -817,13 +861,25 @@ public QueryBuilder<T> equal(Property<T> property, double value, double toleranc
817861
818862 public QueryBuilder <T > less (Property <T > property , double value ) {
819863 verifyHandle ();
820- checkCombineCondition (nativeLess (handle , property .getId (), value ));
864+ checkCombineCondition (nativeLess (handle , property .getId (), value , false ));
865+ return this ;
866+ }
867+
868+ public QueryBuilder <T > lessOrEqual (Property <T > property , double value ) {
869+ verifyHandle ();
870+ checkCombineCondition (nativeLess (handle , property .getId (), value , true ));
821871 return this ;
822872 }
823873
824874 public QueryBuilder <T > greater (Property <T > property , double value ) {
825875 verifyHandle ();
826- checkCombineCondition (nativeGreater (handle , property .getId (), value ));
876+ checkCombineCondition (nativeGreater (handle , property .getId (), value , false ));
877+ return this ;
878+ }
879+
880+ public QueryBuilder <T > greaterOrEqual (Property <T > property , double value ) {
881+ verifyHandle ();
882+ checkCombineCondition (nativeGreater (handle , property .getId (), value , true ));
827883 return this ;
828884 }
829885
@@ -845,13 +901,25 @@ public QueryBuilder<T> equal(Property<T> property, byte[] value) {
845901
846902 public QueryBuilder <T > less (Property <T > property , byte [] value ) {
847903 verifyHandle ();
848- checkCombineCondition (nativeLess (handle , property .getId (), value ));
904+ checkCombineCondition (nativeLess (handle , property .getId (), value , false ));
905+ return this ;
906+ }
907+
908+ public QueryBuilder <T > lessOrEqual (Property <T > property , byte [] value ) {
909+ verifyHandle ();
910+ checkCombineCondition (nativeLess (handle , property .getId (), value , true ));
849911 return this ;
850912 }
851913
852914 public QueryBuilder <T > greater (Property <T > property , byte [] value ) {
853915 verifyHandle ();
854- checkCombineCondition (nativeGreater (handle , property .getId (), value ));
916+ checkCombineCondition (nativeGreater (handle , property .getId (), value , false ));
917+ return this ;
918+ }
919+
920+ public QueryBuilder <T > greaterOrEqual (Property <T > property , byte [] value ) {
921+ verifyHandle ();
922+ checkCombineCondition (nativeGreater (handle , property .getId (), value , true ));
855923 return this ;
856924 }
857925
0 commit comments