|
15 | 15 | /**
|
16 | 16 | * With QueryBuilder you define custom queries returning matching entities. Using the methods of this class you can
|
17 | 17 | * select (filter) results for specific data (for example #{@link #equal(Property, String)} and
|
18 |
| - * {@link #isNull(Property)}) and select an sort order for the resulting list (see {@link #order(Property)} and its overloads). |
| 18 | + * {@link #isNull(Property)}) and select an sort order for the resulting list (see {@link #order(Property)} and its |
| 19 | + * overloads). |
19 | 20 | * <p>
|
20 |
| - * Use {@link #build()} to conclude your query definitions and to get a {@link Query} object, which is used to actually get results. |
| 21 | + * Use {@link #build()} to conclude your query definitions and to get a {@link Query} object, which is used to actually |
| 22 | + * get results. |
21 | 23 | * <p>
|
22 | 24 | * Note: Currently you can only query for complete entities. Returning individual property values or aggregates are
|
23 | 25 | * currently not available. Keep in mind that ObjectBox is very fast and the overhead to create an entity is very low.
|
@@ -443,6 +445,17 @@ public QueryBuilder<T> equal(Property property, String value) {
|
443 | 445 | return this;
|
444 | 446 | }
|
445 | 447 |
|
| 448 | + // Help people with floating point equality... |
| 449 | + /** |
| 450 | + * Floating point equality is non-trivial; this is just a convenience for |
| 451 | + * {@link #between(Property, double, double)} with parameters(property, value - tolerance, value + tolerance). |
| 452 | + * When using {@link Query#setParameters(Property, double, double)}, |
| 453 | + * consider that the params are the lower and upper bounds. |
| 454 | + */ |
| 455 | + public QueryBuilder<T> equal(Property property, double value, double tolerance) { |
| 456 | + return between(property, value - tolerance, value + tolerance); |
| 457 | + } |
| 458 | + |
446 | 459 | public QueryBuilder<T> notEqual(Property property, String value) {
|
447 | 460 | checkCombineCondition(nativeNotEqual(handle, property.getId(), value, false));
|
448 | 461 | return this;
|
|
0 commit comments