Skip to content

Commit b63c8e4

Browse files
Update docs on Index and StringOrder.
1 parent 86d79d5 commit b63c8e4

File tree

3 files changed

+32
-57
lines changed

3 files changed

+32
-57
lines changed

objectbox-java-api/src/main/java/io/objectbox/annotation/Index.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,11 @@
2525
* Specifies that the property should be indexed.
2626
* <p>
2727
* It is highly recommended to index properties that are used in a query to improve query performance.
28+
* When building a query, make sure to use case sensitive String conditions to utilize the index.
2829
* <p>
2930
* To fine tune indexing of a property you can override the default index {@link #type()}.
3031
* <p>
31-
* Note: indexes are currently not supported for byte array, float or double properties.
32+
* Note: indexes are currently not supported for string array, byte array, float or double properties.
3233
*/
3334
@Retention(RetentionPolicy.CLASS)
3435
@Target(ElementType.FIELD)

objectbox-java/src/main/java/io/objectbox/Property.java

Lines changed: 18 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -334,15 +334,8 @@ public PropertyQueryCondition<ENTITY> between(Date lowerBoundary, Date upperBoun
334334
}
335335

336336
/**
337-
* Creates an "equal ('=')" condition for this property.
338-
* <p>
339-
* Case sensitive when matching results, e.g. {@code equal("example")} only matches "example", but not "Example".
340-
* <p>
341-
* Use {@link #equal(String, StringOrder) equal(value, StringOrder.CASE_INSENSITIVE)} to also match
342-
* if case is different.
343-
* <p>
344-
* Note: Use a case sensitive condition to utilize an {@link io.objectbox.annotation.Index @Index}
345-
* on {@code property}, dramatically speeding up look-up of results.
337+
* Creates an "equal ('=')" condition for this property
338+
* using {@link StringOrder#CASE_SENSITIVE StringOrder#CASE_SENSITIVE}.
346339
*
347340
* @see #equal(String, StringOrder)
348341
*/
@@ -352,28 +345,14 @@ public PropertyQueryCondition<ENTITY> equal(String value) {
352345

353346
/**
354347
* Creates an "equal ('=')" condition for this property.
355-
* <p>
356-
* Set {@code order} to {@link StringOrder#CASE_INSENSITIVE StringOrder.CASE_INSENSITIVE} to also match
357-
* if case is not equal. E.g. {@code equal("example", StringOrder.CASE_INSENSITIVE)}
358-
* matches "example" and "Example".
359-
* <p>
360-
* Note: Use a case sensitive condition to utilize an {@link io.objectbox.annotation.Index @Index}
361-
* on {@code property}, dramatically speeding up look-up of results.
362348
*/
363349
public PropertyQueryCondition<ENTITY> equal(String value, StringOrder order) {
364350
return new StringCondition<>(this, StringCondition.Operation.EQUAL, value, order);
365351
}
366352

367353
/**
368-
* Creates a "not equal ('&lt;&gt;')" condition for this property.
369-
* <p>
370-
* Case sensitive when matching results, e.g. {@code notEqual("example")} excludes only "example", but not "Example".
371-
* <p>
372-
* Use {@link #notEqual(String, StringOrder) notEqual(value, StringOrder.CASE_INSENSITIVE)} to also exclude
373-
* if case is different.
374-
* <p>
375-
* Note: Use a case sensitive condition to utilize an {@link io.objectbox.annotation.Index @Index}
376-
* on {@code property}, dramatically speeding up look-up of results.
354+
* Creates a "not equal ('&lt;&gt;')" condition for this property
355+
* using {@link StringOrder#CASE_SENSITIVE StringOrder#CASE_SENSITIVE}.
377356
*
378357
* @see #notEqual(String, StringOrder)
379358
*/
@@ -383,23 +362,14 @@ public PropertyQueryCondition<ENTITY> notEqual(String value) {
383362

384363
/**
385364
* Creates a "not equal ('&lt;&gt;')" condition for this property.
386-
* <p>
387-
* Set {@code order} to {@link StringOrder#CASE_INSENSITIVE StringOrder.CASE_INSENSITIVE} to also exclude
388-
* if case is different. E.g. {@code notEqual("example", StringOrder.CASE_INSENSITIVE)}
389-
* excludes both "example" and "Example".
390-
* <p>
391-
* Note: Use a case sensitive condition to utilize an {@link io.objectbox.annotation.Index @Index}
392-
* on {@code property}, dramatically speeding up look-up of results.
393365
*/
394366
public PropertyQueryCondition<ENTITY> notEqual(String value, StringOrder order) {
395367
return new StringCondition<>(this, StringCondition.Operation.NOT_EQUAL, value, order);
396368
}
397369

398370
/**
399-
* Creates a "greater than ('&gt;')" condition for this property.
400-
* <p>
401-
* Case sensitive when matching results. Use the overload and pass
402-
* {@link StringOrder#CASE_INSENSITIVE StringOrder.CASE_INSENSITIVE} to specify that case should be ignored.
371+
* Creates a "greater than ('&gt;')" condition for this property
372+
* using {@link StringOrder#CASE_SENSITIVE StringOrder#CASE_SENSITIVE}.
403373
*
404374
* @see #greater(String, StringOrder)
405375
*/
@@ -422,10 +392,8 @@ public PropertyQueryCondition<ENTITY> greaterOrEqual(String value, StringOrder o
422392
}
423393

424394
/**
425-
* Creates a "less than ('&lt;')" condition for this property.
426-
* <p>
427-
* Case sensitive when matching results. Use the overload and pass
428-
* {@link StringOrder#CASE_INSENSITIVE StringOrder.CASE_INSENSITIVE} to specify that case should be ignored.
395+
* Creates a "less than ('&lt;')" condition for this property
396+
* using {@link StringOrder#CASE_SENSITIVE StringOrder#CASE_SENSITIVE}.
429397
*
430398
* @see #less(String, StringOrder)
431399
*/
@@ -448,8 +416,8 @@ public PropertyQueryCondition<ENTITY> lessOrEqual(String value, StringOrder orde
448416
}
449417

450418
/**
451-
* Case sensitive when matching results. Use the overload and pass
452-
* {@link StringOrder#CASE_INSENSITIVE StringOrder.CASE_INSENSITIVE} to specify that case should be ignored.
419+
* Creates a contains condition for this property
420+
* using {@link StringOrder#CASE_SENSITIVE StringOrder#CASE_SENSITIVE}.
453421
* <p>
454422
* Note: for a String array property, use {@link #containsElement} instead.
455423
*
@@ -472,10 +440,10 @@ private void checkNotStringArray() {
472440
}
473441

474442
/**
475-
* For a String array property, matches if at least one element equals the given value.
476-
* <p>
477-
* Case sensitive when matching results. Use the overload and pass
478-
* {@link StringOrder#CASE_INSENSITIVE StringOrder.CASE_INSENSITIVE} to specify that case should be ignored.
443+
* For a String array property, matches if at least one element equals the given value
444+
* using {@link StringOrder#CASE_SENSITIVE StringOrder#CASE_SENSITIVE}.
445+
*
446+
* @see #containsElement(String, StringOrder)
479447
*/
480448
public PropertyQueryCondition<ENTITY> containsElement(String value) {
481449
checkIsStringArray();
@@ -494,8 +462,7 @@ private void checkIsStringArray() {
494462
}
495463

496464
/**
497-
* Case sensitive when matching results. Use the overload and pass
498-
* {@link StringOrder#CASE_INSENSITIVE StringOrder.CASE_INSENSITIVE} to specify that case should be ignored.
465+
* Creates a starts with condition using {@link StringOrder#CASE_SENSITIVE StringOrder#CASE_SENSITIVE}.
499466
*
500467
* @see #startsWith(String, StringOrder)
501468
*/
@@ -508,8 +475,7 @@ public PropertyQueryCondition<ENTITY> startsWith(String value, StringOrder order
508475
}
509476

510477
/**
511-
* Case sensitive when matching results. Use the overload and pass
512-
* {@link StringOrder#CASE_INSENSITIVE StringOrder.CASE_INSENSITIVE} to specify that case should be ignored.
478+
* Creates an ends with condition using {@link StringOrder#CASE_SENSITIVE StringOrder#CASE_SENSITIVE}.
513479
*
514480
* @see #endsWith(String, StringOrder)
515481
*/
@@ -522,10 +488,8 @@ public PropertyQueryCondition<ENTITY> endsWith(String value, StringOrder order)
522488
}
523489

524490
/**
525-
* Creates an "IN (..., ..., ...)" condition for this property.
526-
* <p>
527-
* Case sensitive when matching results. Use the overload and pass
528-
* {@link StringOrder#CASE_INSENSITIVE StringOrder.CASE_INSENSITIVE} to specify that case should be ignored.
491+
* Creates an "IN (..., ..., ...)" condition for this property
492+
* using {@link StringOrder#CASE_SENSITIVE StringOrder#CASE_SENSITIVE}.
529493
*
530494
* @see #oneOf(String[], StringOrder)
531495
*/

objectbox-java/src/main/java/io/objectbox/query/QueryBuilder.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,20 @@
6161
public class QueryBuilder<T> implements Closeable {
6262

6363
public enum StringOrder {
64-
/** The default: case insensitive ASCII characters */
64+
/**
65+
* Ignores case of ASCII characters when matching results,
66+
* e.g. the condition "= example" matches both "Example" and "example".
67+
* <p>
68+
* Note: To utilize an index on a property use {@link #CASE_SENSITIVE} instead.
69+
*/
6570
CASE_INSENSITIVE,
6671

67-
/** Case matters ('a' != 'A'). */
72+
/**
73+
* Checks case of ASCII characters when macthing results,
74+
* e.g. the condition "= example" only matches "example", but not "Example".
75+
* <p>
76+
* Use this if the property has an index.
77+
*/
6878
CASE_SENSITIVE
6979
}
7080

0 commit comments

Comments
 (0)