|
1 | 1 | /*
|
2 |
| - * Copyright 2017 ObjectBox Ltd. All rights reserved. |
| 2 | + * Copyright 2017-2018 ObjectBox Ltd. All rights reserved. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
@@ -119,7 +119,6 @@ private native long nativeLink(long handle, long storeHandle, int relationOwnerE
|
119 | 119 |
|
120 | 120 | private native void nativeSetParameterAlias(long conditionHandle, String alias);
|
121 | 121 |
|
122 |
| - |
123 | 122 | // ------------------------------ (Not)Null------------------------------
|
124 | 123 |
|
125 | 124 | private native long nativeNull(long handle, int propertyId);
|
@@ -161,12 +160,21 @@ private native long nativeLink(long handle, long storeHandle, int relationOwnerE
|
161 | 160 | private native long nativeIn(long handle, int propertyId, String[] value, boolean caseSensitive);
|
162 | 161 |
|
163 | 162 | // ------------------------------ FPs ------------------------------
|
| 163 | + |
164 | 164 | private native long nativeLess(long handle, int propertyId, double value);
|
165 | 165 |
|
166 | 166 | private native long nativeGreater(long handle, int propertyId, double value);
|
167 | 167 |
|
168 | 168 | private native long nativeBetween(long handle, int propertyId, double value1, double value2);
|
169 | 169 |
|
| 170 | + // ------------------------------ Bytes ------------------------------ |
| 171 | + |
| 172 | + private native long nativeEqual(long handle, int propertyId, byte[] value); |
| 173 | + |
| 174 | + private native long nativeLess(long handle, int propertyId, byte[] value); |
| 175 | + |
| 176 | + private native long nativeGreater(long handle, int propertyId, byte[] value); |
| 177 | + |
170 | 178 | @Internal
|
171 | 179 | public QueryBuilder(Box<T> box, long storeHandle, String entityName) {
|
172 | 180 | this.box = box;
|
@@ -282,6 +290,21 @@ public QueryBuilder<T> sort(Comparator<T> comparator) {
|
282 | 290 | return this;
|
283 | 291 | }
|
284 | 292 |
|
| 293 | + |
| 294 | + /** |
| 295 | + * Asigns the given alias to the previous condition. |
| 296 | + * |
| 297 | + * @param alias The string alias for use with setParameter(s) methods. |
| 298 | + */ |
| 299 | + public QueryBuilder<T> parameterAlias(String alias) { |
| 300 | + verifyHandle(); |
| 301 | + if (lastCondition == 0) { |
| 302 | + throw new IllegalStateException("No previous condition. Before you can assign an alias, you must first have a condition."); |
| 303 | + } |
| 304 | + nativeSetParameterAlias(lastCondition, alias); |
| 305 | + return this; |
| 306 | + } |
| 307 | + |
285 | 308 | /**
|
286 | 309 | * Creates a link to another entity, for which you also can describe conditions using the returned builder.
|
287 | 310 | * <p>
|
@@ -693,12 +716,25 @@ public QueryBuilder<T> between(Property<T> property, double value1, double value
|
693 | 716 | return this;
|
694 | 717 | }
|
695 | 718 |
|
696 |
| - public QueryBuilder<T> parameterAlias(String alias) { |
| 719 | + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 720 | + // Bytes |
| 721 | + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
| 722 | + |
| 723 | + public QueryBuilder<T> equal(Property<T> property, byte[] value) { |
697 | 724 | verifyHandle();
|
698 |
| - if (lastCondition == 0) { |
699 |
| - throw new IllegalStateException("No previous condition. Before you can assign an alias, you must first have a condition."); |
700 |
| - } |
701 |
| - nativeSetParameterAlias(lastCondition, alias); |
| 725 | + checkCombineCondition(nativeEqual(handle, property.getId(), value)); |
| 726 | + return this; |
| 727 | + } |
| 728 | + |
| 729 | + public QueryBuilder<T> less(Property<T> property, byte[] value) { |
| 730 | + verifyHandle(); |
| 731 | + checkCombineCondition(nativeLess(handle, property.getId(), value)); |
| 732 | + return this; |
| 733 | + } |
| 734 | + |
| 735 | + public QueryBuilder<T> greater(Property<T> property, byte[] value) { |
| 736 | + verifyHandle(); |
| 737 | + checkCombineCondition(nativeGreater(handle, property.getId(), value)); |
702 | 738 | return this;
|
703 | 739 | }
|
704 | 740 |
|
|
0 commit comments