Skip to content

Commit a3aea9a

Browse files
Document how to use case sensitive conditions for String properties.
1 parent c1afae1 commit a3aea9a

File tree

1 file changed

+96
-10
lines changed

1 file changed

+96
-10
lines changed

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

Lines changed: 96 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -215,46 +215,111 @@ public PropertyQueryCondition<ENTITY> between(Date lowerBoundary, Date upperBoun
215215
return new LongLongCondition<>(this, LongLongCondition.Operation.BETWEEN, lowerBoundary, upperBoundary);
216216
}
217217

218-
/** Creates an "equal ('=')" condition for this property. */
218+
/**
219+
* Creates an "equal ('=')" condition for this property.
220+
* <p>
221+
* Ignores case when matching results, e.g. {@code equal("example")} matches both "Example" and "example".
222+
* <p>
223+
* Use {@link #equal(String, StringOrder) equal(value, StringOrder.CASE_SENSITIVE)} to only match if case is equal.
224+
* <p>
225+
* Note: Use a case sensitive condition to utilize an {@link io.objectbox.annotation.Index @Index}
226+
* on {@code property}, dramatically speeding up look-up of results.
227+
*
228+
* @see #equal(String, StringOrder)
229+
*/
219230
public PropertyQueryCondition<ENTITY> equal(String value) {
220231
return new StringCondition<>(this, StringCondition.Operation.EQUAL, value);
221232
}
222233

223-
/** Creates an "equal ('=')" condition for this property. */
234+
/**
235+
* Creates an "equal ('=')" condition for this property.
236+
* <p>
237+
* Set {@code order} to {@link StringOrder#CASE_SENSITIVE StringOrder.CASE_SENSITIVE} to only match
238+
* if case is equal. E.g. {@code equal("example", StringOrder.CASE_SENSITIVE)} only matches "example",
239+
* but not "Example".
240+
* <p>
241+
* Note: Use a case sensitive condition to utilize an {@link io.objectbox.annotation.Index @Index}
242+
* on {@code property}, dramatically speeding up look-up of results.
243+
*/
224244
public PropertyQueryCondition<ENTITY> equal(String value, StringOrder order) {
225245
return new StringCondition<>(this, StringCondition.Operation.EQUAL, value, order);
226246
}
227247

228-
/** Creates a "not equal ('&lt;&gt;')" condition for this property. */
248+
/**
249+
* Creates a "not equal ('&lt;&gt;')" condition for this property.
250+
* <p>
251+
* Ignores case when matching results, e.g. {@code notEqual("example")} excludes both "Example" and "example".
252+
* <p>
253+
* Use {@link #notEqual(String, StringOrder) notEqual(value, StringOrder.CASE_SENSITIVE)} to only exclude
254+
* if case is equal.
255+
* <p>
256+
* Note: Use a case sensitive condition to utilize an {@link io.objectbox.annotation.Index @Index}
257+
* on {@code property}, dramatically speeding up look-up of results.
258+
*
259+
* @see #notEqual(String, StringOrder)
260+
*/
229261
public PropertyQueryCondition<ENTITY> notEqual(String value) {
230262
return new StringCondition<>(this, StringCondition.Operation.NOT_EQUAL, value);
231263
}
232264

233-
/** Creates a "not equal ('&lt;&gt;')" condition for this property. */
265+
/**
266+
* Creates a "not equal ('&lt;&gt;')" condition for this property.
267+
* <p>
268+
* Set {@code order} to {@link StringOrder#CASE_SENSITIVE StringOrder.CASE_SENSITIVE} to only exclude
269+
* if case is equal. E.g. {@code notEqual("example", StringOrder.CASE_SENSITIVE)} only excludes "example",
270+
* but not "Example".
271+
* <p>
272+
* Note: Use a case sensitive condition to utilize an {@link io.objectbox.annotation.Index @Index}
273+
* on {@code property}, dramatically speeding up look-up of results.
274+
*/
234275
public PropertyQueryCondition<ENTITY> notEqual(String value, StringOrder order) {
235276
return new StringCondition<>(this, StringCondition.Operation.NOT_EQUAL, value, order);
236277
}
237278

238-
/** Creates a "greater than ('&gt;')" condition for this property. */
279+
/**
280+
* Creates a "greater than ('&gt;')" condition for this property.
281+
* <p>
282+
* Ignores case when matching results. Use the overload and pass
283+
* {@link StringOrder#CASE_SENSITIVE StringOrder.CASE_SENSITIVE} to specify that case should not be ignored.
284+
*
285+
* @see #greater(String, StringOrder)
286+
*/
239287
public PropertyQueryCondition<ENTITY> greater(String value) {
240288
return new StringCondition<>(this, StringCondition.Operation.GREATER, value);
241289
}
242290

243-
/** Creates a "greater than ('&gt;')" condition for this property. */
291+
/**
292+
* Creates a "greater than ('&gt;')" condition for this property.
293+
*/
244294
public PropertyQueryCondition<ENTITY> greater(String value, StringOrder order) {
245295
return new StringCondition<>(this, StringCondition.Operation.GREATER, value, order);
246296
}
247297

248-
/** Creates a "less than ('&lt;')" condition for this property. */
298+
/**
299+
* Creates a "less than ('&lt;')" condition for this property.
300+
* <p>
301+
* Ignores case when matching results. Use the overload and pass
302+
* {@link StringOrder#CASE_SENSITIVE StringOrder.CASE_SENSITIVE} to specify that case should not be ignored.
303+
*
304+
* @see #less(String, StringOrder)
305+
*/
249306
public PropertyQueryCondition<ENTITY> less(String value) {
250307
return new StringCondition<>(this, StringCondition.Operation.LESS, value);
251308
}
252309

253-
/** Creates a "less than ('&lt;')" condition for this property. */
310+
/**
311+
* Creates a "less than ('&lt;')" condition for this property.
312+
*/
254313
public PropertyQueryCondition<ENTITY> less(String value, StringOrder order) {
255314
return new StringCondition<>(this, StringCondition.Operation.LESS, value, order);
256315
}
257316

317+
/**
318+
* Ignores case when matching results. Use the overload and pass
319+
* {@link StringOrder#CASE_SENSITIVE StringOrder.CASE_SENSITIVE} to specify that case should not be ignored.
320+
*
321+
* @see #contains(String, StringOrder)
322+
*/
258323
public PropertyQueryCondition<ENTITY> contains(String value) {
259324
return new StringCondition<>(this, StringCondition.Operation.CONTAINS, value);
260325
}
@@ -263,6 +328,12 @@ public PropertyQueryCondition<ENTITY> contains(String value, StringOrder order)
263328
return new StringCondition<>(this, StringCondition.Operation.CONTAINS, value, order);
264329
}
265330

331+
/**
332+
* Ignores case when matching results. Use the overload and pass
333+
* {@link StringOrder#CASE_SENSITIVE StringOrder.CASE_SENSITIVE} to specify that case should not be ignored.
334+
*
335+
* @see #startsWith(String, StringOrder)
336+
*/
266337
public PropertyQueryCondition<ENTITY> startsWith(String value) {
267338
return new StringCondition<>(this, Operation.STARTS_WITH, value);
268339
}
@@ -271,6 +342,12 @@ public PropertyQueryCondition<ENTITY> startsWith(String value, StringOrder order
271342
return new StringCondition<>(this, Operation.STARTS_WITH, value, order);
272343
}
273344

345+
/**
346+
* Ignores case when matching results. Use the overload and pass
347+
* {@link StringOrder#CASE_SENSITIVE StringOrder.CASE_SENSITIVE} to specify that case should not be ignored.
348+
*
349+
* @see #endsWith(String, StringOrder)
350+
*/
274351
public PropertyQueryCondition<ENTITY> endsWith(String value) {
275352
return new StringCondition<>(this, Operation.ENDS_WITH, value);
276353
}
@@ -279,12 +356,21 @@ public PropertyQueryCondition<ENTITY> endsWith(String value, StringOrder order)
279356
return new StringCondition<>(this, Operation.ENDS_WITH, value, order);
280357
}
281358

282-
/** Creates an "IN (..., ..., ...)" condition for this property. */
359+
/**
360+
* Creates an "IN (..., ..., ...)" condition for this property.
361+
* <p>
362+
* Ignores case when matching results. Use the overload and pass
363+
* {@link StringOrder#CASE_SENSITIVE StringOrder.CASE_SENSITIVE} to specify that case should not be ignored.
364+
*
365+
* @see #oneOf(String[], StringOrder)
366+
*/
283367
public PropertyQueryCondition<ENTITY> oneOf(String[] values) {
284368
return new StringArrayCondition<>(this, StringArrayCondition.Operation.IN, values);
285369
}
286370

287-
/** Creates an "IN (..., ..., ...)" condition for this property. */
371+
/**
372+
* Creates an "IN (..., ..., ...)" condition for this property.
373+
*/
288374
public PropertyQueryCondition<ENTITY> oneOf(String[] values, StringOrder order) {
289375
return new StringArrayCondition<>(this, StringArrayCondition.Operation.IN, values, order);
290376
}

0 commit comments

Comments
 (0)