38
38
*
39
39
* <pre>
40
40
* userBox.query()
41
- * .equal(User_.firstName, "Joe")
41
+ * .equal(User_.firstName, "Joe", StringOrder.CASE_SENSITIVE )
42
42
* .order(User_.lastName)
43
43
* .build()
44
44
* .find()
45
45
* </pre>
46
46
*
47
47
* <p>
48
- * To add a condition use the appropriate method, for example {@link #equal(Property, String)} or
48
+ * To add a condition use the appropriate method, for example {@link #equal(Property, String, StringOrder )} or
49
49
* {@link #isNull(Property)}. To order results use {@link #order(Property)} and its related methods.
50
50
* <p>
51
51
* Use {@link #build()} to create a {@link Query} object, which is used to actually get the results.
@@ -70,10 +70,11 @@ public enum StringOrder {
70
70
CASE_INSENSITIVE ,
71
71
72
72
/**
73
- * Checks case of ASCII characters when macthing results,
73
+ * Checks case of ASCII characters when matching results,
74
74
* e.g. the condition "= example" only matches "example", but not "Example".
75
75
* <p>
76
- * Use this if the property has an index.
76
+ * Use this if the property has an {@link io.objectbox.annotation.Index @Index}
77
+ * to dramatically increase the speed of looking-up results.
77
78
*/
78
79
CASE_SENSITIVE
79
80
}
@@ -449,7 +450,7 @@ public QueryBuilder<T> eager(int limit, RelationInfo relationInfo, @Nullable Rel
449
450
450
451
/**
451
452
* Sets a filter that executes on primary query results (returned from the db core) on a Java level.
452
- * For efficiency reasons, you should always prefer primary criteria like {@link #equal(Property, String )} if
453
+ * For efficiency reasons, you should always prefer primary criteria like {@link #equal(Property, long )} if
453
454
* possible.
454
455
* A filter requires to instantiate full Java objects beforehand, which is less efficient.
455
456
* <p>
@@ -733,30 +734,6 @@ public QueryBuilder<T> between(Property<T> property, Date value1, Date value2) {
733
734
734
735
/**
735
736
* Creates an "equal ('=')" condition for this property.
736
- * <p>
737
- * Ignores case when matching results, e.g. {@code equal(prop, "example")} matches both "Example" and "example".
738
- * <p>
739
- * Use {@link #equal(Property, String, StringOrder) equal(prop, value, StringOrder.CASE_SENSITIVE)} to only match
740
- * if case is equal.
741
- * <p>
742
- * Note: Use a case sensitive condition to utilize an {@link io.objectbox.annotation.Index @Index}
743
- * on {@code property}, dramatically speeding up look-up of results.
744
- */
745
- public QueryBuilder <T > equal (Property <T > property , String value ) {
746
- verifyHandle ();
747
- checkCombineCondition (nativeEqual (handle , property .getId (), value , false ));
748
- return this ;
749
- }
750
-
751
- /**
752
- * Creates an "equal ('=')" condition for this property.
753
- * <p>
754
- * Set {@code order} to {@link StringOrder#CASE_SENSITIVE StringOrder.CASE_SENSITIVE} to only match
755
- * if case is equal. E.g. {@code equal(prop, "example", StringOrder.CASE_SENSITIVE)} only matches "example",
756
- * but not "Example".
757
- * <p>
758
- * Note: Use a case sensitive condition to utilize an {@link io.objectbox.annotation.Index @Index}
759
- * on {@code property}, dramatically speeding up look-up of results.
760
737
*/
761
738
public QueryBuilder <T > equal (Property <T > property , String value , StringOrder order ) {
762
739
verifyHandle ();
@@ -766,30 +743,6 @@ public QueryBuilder<T> equal(Property<T> property, String value, StringOrder ord
766
743
767
744
/**
768
745
* Creates a "not equal ('<>')" condition for this property.
769
- * <p>
770
- * Ignores case when matching results, e.g. {@code notEqual(prop, "example")} excludes both "Example" and "example".
771
- * <p>
772
- * Use {@link #notEqual(Property, String, StringOrder) notEqual(prop, value, StringOrder.CASE_SENSITIVE)} to only exclude
773
- * if case is equal.
774
- * <p>
775
- * Note: Use a case sensitive condition to utilize an {@link io.objectbox.annotation.Index @Index}
776
- * on {@code property}, dramatically speeding up look-up of results.
777
- */
778
- public QueryBuilder <T > notEqual (Property <T > property , String value ) {
779
- verifyHandle ();
780
- checkCombineCondition (nativeNotEqual (handle , property .getId (), value , false ));
781
- return this ;
782
- }
783
-
784
- /**
785
- * Creates a "not equal ('<>')" condition for this property.
786
- * <p>
787
- * Set {@code order} to {@link StringOrder#CASE_SENSITIVE StringOrder.CASE_SENSITIVE} to only exclude
788
- * if case is equal. E.g. {@code notEqual(prop, "example", StringOrder.CASE_SENSITIVE)} only excludes "example",
789
- * but not "Example".
790
- * <p>
791
- * Note: Use a case sensitive condition to utilize an {@link io.objectbox.annotation.Index @Index}
792
- * on {@code property}, dramatically speeding up look-up of results.
793
746
*/
794
747
public QueryBuilder <T > notEqual (Property <T > property , String value , StringOrder order ) {
795
748
verifyHandle ();
@@ -798,56 +751,32 @@ public QueryBuilder<T> notEqual(Property<T> property, String value, StringOrder
798
751
}
799
752
800
753
/**
801
- * Ignores case when matching results. Use the overload and pass
802
- * {@link StringOrder#CASE_SENSITIVE StringOrder.CASE_SENSITIVE} to specify that case should not be ignored.
754
+ * Creates an contains condition.
803
755
* <p>
804
756
* Note: for a String array property, use {@link #containsElement} instead.
805
757
*/
806
- public QueryBuilder <T > contains (Property <T > property , String value ) {
758
+ public QueryBuilder <T > contains (Property <T > property , String value , StringOrder order ) {
807
759
if (String [].class == property .type ) {
808
760
throw new UnsupportedOperationException ("For String[] only containsElement() is supported at this time." );
809
761
}
810
- verifyHandle ();
811
- checkCombineCondition (nativeContains (handle , property .getId (), value , false ));
762
+ containsNoTypeCheck (property , value , order );
812
763
return this ;
813
764
}
814
765
815
766
/**
816
767
* For a String array property, matches if at least one element equals the given value.
817
768
*/
818
- public QueryBuilder <T > containsElement (Property <T > property , String value ) {
769
+ public QueryBuilder <T > containsElement (Property <T > property , String value , StringOrder order ) {
819
770
if (String [].class != property .type ) {
820
771
throw new IllegalArgumentException ("containsElement is only supported for String[] properties." );
821
772
}
822
- verifyHandle ();
823
- checkCombineCondition (nativeContains (handle , property .getId (), value , false ));
773
+ containsNoTypeCheck (property , value , order );
824
774
return this ;
825
775
}
826
776
827
- /**
828
- * Ignores case when matching results. Use the overload and pass
829
- * {@link StringOrder#CASE_SENSITIVE StringOrder.CASE_SENSITIVE} to specify that case should not be ignored.
830
- */
831
- public QueryBuilder <T > startsWith (Property <T > property , String value ) {
832
- verifyHandle ();
833
- checkCombineCondition (nativeStartsWith (handle , property .getId (), value , false ));
834
- return this ;
835
- }
836
-
837
- /**
838
- * Ignores case when matching results. Use the overload and pass
839
- * {@link StringOrder#CASE_SENSITIVE StringOrder.CASE_SENSITIVE} to specify that case should not be ignored.
840
- */
841
- public QueryBuilder <T > endsWith (Property <T > property , String value ) {
842
- verifyHandle ();
843
- checkCombineCondition (nativeEndsWith (handle , property .getId (), value , false ));
844
- return this ;
845
- }
846
-
847
- public QueryBuilder <T > contains (Property <T > property , String value , StringOrder order ) {
777
+ void containsNoTypeCheck (Property <T > property , String value , StringOrder order ) {
848
778
verifyHandle ();
849
779
checkCombineCondition (nativeContains (handle , property .getId (), value , order == StringOrder .CASE_SENSITIVE ));
850
- return this ;
851
780
}
852
781
853
782
public QueryBuilder <T > startsWith (Property <T > property , String value , StringOrder order ) {
@@ -862,14 +791,6 @@ public QueryBuilder<T> endsWith(Property<T> property, String value, StringOrder
862
791
return this ;
863
792
}
864
793
865
- /**
866
- * Ignores case when matching results. Use the overload and pass
867
- * {@link StringOrder#CASE_SENSITIVE StringOrder.CASE_SENSITIVE} to specify that case should not be ignored.
868
- */
869
- public QueryBuilder <T > less (Property <T > property , String value ) {
870
- return less (property , value , StringOrder .CASE_INSENSITIVE );
871
- }
872
-
873
794
public QueryBuilder <T > less (Property <T > property , String value , StringOrder order ) {
874
795
verifyHandle ();
875
796
checkCombineCondition (nativeLess (handle , property .getId (), value , order == StringOrder .CASE_SENSITIVE , false ));
@@ -882,14 +803,6 @@ public QueryBuilder<T> lessOrEqual(Property<T> property, String value, StringOrd
882
803
return this ;
883
804
}
884
805
885
- /**
886
- * Ignores case when matching results. Use the overload and pass
887
- * {@link StringOrder#CASE_SENSITIVE StringOrder.CASE_SENSITIVE} to specify that case should not be ignored.
888
- */
889
- public QueryBuilder <T > greater (Property <T > property , String value ) {
890
- return greater (property , value , StringOrder .CASE_INSENSITIVE );
891
- }
892
-
893
806
public QueryBuilder <T > greater (Property <T > property , String value , StringOrder order ) {
894
807
verifyHandle ();
895
808
checkCombineCondition (nativeGreater (handle , property .getId (), value , order == StringOrder .CASE_SENSITIVE , false ));
@@ -902,14 +815,6 @@ public QueryBuilder<T> greaterOrEqual(Property<T> property, String value, String
902
815
return this ;
903
816
}
904
817
905
- /**
906
- * Ignores case when matching results. Use the overload and pass
907
- * {@link StringOrder#CASE_SENSITIVE StringOrder.CASE_SENSITIVE} to specify that case should not be ignored.
908
- */
909
- public QueryBuilder <T > in (Property <T > property , String [] values ) {
910
- return in (property , values , StringOrder .CASE_INSENSITIVE );
911
- }
912
-
913
818
public QueryBuilder <T > in (Property <T > property , String [] values , StringOrder order ) {
914
819
verifyHandle ();
915
820
checkCombineCondition (nativeIn (handle , property .getId (), values , order == StringOrder .CASE_SENSITIVE ));
0 commit comments