Skip to content

Commit 956c76b

Browse files
Add Property condition method overloads for short and long.
Also add matching infix functions.
1 parent 50918aa commit 956c76b

2 files changed

Lines changed: 97 additions & 5 deletions

File tree

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

Lines changed: 55 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,56 @@ public PropertyQueryCondition<ENTITY> notEqual(boolean value) {
123123
return new LongCondition<>(this, LongCondition.Operation.NOT_EQUAL, value);
124124
}
125125

126+
/** Creates an "equal ('=')" condition for this property. */
127+
public PropertyQueryCondition<ENTITY> equal(short value) {
128+
return equal((long) value);
129+
}
130+
131+
/** Creates a "not equal ('&lt;&gt;')" condition for this property. */
132+
public PropertyQueryCondition<ENTITY> notEqual(short value) {
133+
return notEqual((long) value);
134+
}
135+
136+
/** Creates a "greater than ('&gt;')" condition for this property. */
137+
public PropertyQueryCondition<ENTITY> greater(short value) {
138+
return greater((long) value);
139+
}
140+
141+
/** Creates a "less than ('&lt;')" condition for this property. */
142+
public PropertyQueryCondition<ENTITY> less(short value) {
143+
return less((long) value);
144+
}
145+
146+
/** Creates an "BETWEEN ... AND ..." condition for this property. */
147+
public PropertyQueryCondition<ENTITY> between(short lowerBoundary, short upperBoundary) {
148+
return between((long) lowerBoundary, upperBoundary);
149+
}
150+
151+
/** Creates an "equal ('=')" condition for this property. */
152+
public PropertyQueryCondition<ENTITY> equal(int value) {
153+
return equal((long) value);
154+
}
155+
156+
/** Creates a "not equal ('&lt;&gt;')" condition for this property. */
157+
public PropertyQueryCondition<ENTITY> notEqual(int value) {
158+
return notEqual((long) value);
159+
}
160+
161+
/** Creates a "greater than ('&gt;')" condition for this property. */
162+
public PropertyQueryCondition<ENTITY> greater(int value) {
163+
return greater((long) value);
164+
}
165+
166+
/** Creates a "less than ('&lt;')" condition for this property. */
167+
public PropertyQueryCondition<ENTITY> less(int value) {
168+
return less((long) value);
169+
}
170+
171+
/** Creates an "BETWEEN ... AND ..." condition for this property. */
172+
public PropertyQueryCondition<ENTITY> between(int lowerBoundary, int upperBoundary) {
173+
return between((long) lowerBoundary, upperBoundary);
174+
}
175+
126176
/** Creates an "IN (..., ..., ...)" condition for this property. */
127177
public PropertyQueryCondition<ENTITY> oneOf(int[] values) {
128178
return new IntArrayCondition<>(this, IntArrayCondition.Operation.IN, values);
@@ -153,6 +203,11 @@ public PropertyQueryCondition<ENTITY> less(long value) {
153203
return new LongCondition<>(this, LongCondition.Operation.LESS, value);
154204
}
155205

206+
/** Creates an "BETWEEN ... AND ..." condition for this property. */
207+
public PropertyQueryCondition<ENTITY> between(long lowerBoundary, long upperBoundary) {
208+
return new LongLongCondition<>(this, LongLongCondition.Operation.BETWEEN, lowerBoundary, upperBoundary);
209+
}
210+
156211
/** Creates an "IN (..., ..., ...)" condition for this property. */
157212
public PropertyQueryCondition<ENTITY> oneOf(long[] values) {
158213
return new LongArrayCondition<>(this, LongArrayCondition.Operation.IN, values);
@@ -163,11 +218,6 @@ public PropertyQueryCondition<ENTITY> notOneOf(long[] values) {
163218
return new LongArrayCondition<>(this, LongArrayCondition.Operation.NOT_IN, values);
164219
}
165220

166-
/** Creates an "BETWEEN ... AND ..." condition for this property. */
167-
public PropertyQueryCondition<ENTITY> between(long lowerBoundary, long upperBoundary) {
168-
return new LongLongCondition<>(this, LongLongCondition.Operation.BETWEEN, lowerBoundary, upperBoundary);
169-
}
170-
171221
/**
172222
* Calls {@link #between(double, double)} with {@code value - tolerance} as lower bound and
173223
* {@code value + tolerance} as upper bound.

objectbox-kotlin/src/main/kotlin/io/objectbox/kotlin/Property.kt

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,48 @@ infix fun <T> Property<T>.notEqual(value: Boolean): PropertyQueryCondition<T> {
3434
return notEqual(value)
3535
}
3636

37+
// Short
38+
/** Creates an "equal ('=')" condition for this property. */
39+
infix fun <T> Property<T>.equal(value: Short): PropertyQueryCondition<T> {
40+
return equal(value)
41+
}
42+
43+
/** Creates a "not equal ('&lt;&gt;')" condition for this property. */
44+
infix fun <T> Property<T>.notEqual(value: Short): PropertyQueryCondition<T> {
45+
return notEqual(value)
46+
}
47+
48+
/** Creates a "greater than ('&gt;')" condition for this property. */
49+
infix fun <T> Property<T>.greater(value: Short): PropertyQueryCondition<T> {
50+
return greater(value)
51+
}
52+
53+
/** Creates a "less than ('&lt;')" condition for this property. */
54+
infix fun <T> Property<T>.less(value: Short): PropertyQueryCondition<T> {
55+
return less(value)
56+
}
57+
58+
// Int
59+
/** Creates an "equal ('=')" condition for this property. */
60+
infix fun <T> Property<T>.equal(value: Int): PropertyQueryCondition<T> {
61+
return equal(value)
62+
}
63+
64+
/** Creates a "not equal ('&lt;&gt;')" condition for this property. */
65+
infix fun <T> Property<T>.notEqual(value: Int): PropertyQueryCondition<T> {
66+
return notEqual(value)
67+
}
68+
69+
/** Creates a "greater than ('&gt;')" condition for this property. */
70+
infix fun <T> Property<T>.greater(value: Int): PropertyQueryCondition<T> {
71+
return greater(value)
72+
}
73+
74+
/** Creates a "less than ('&lt;')" condition for this property. */
75+
infix fun <T> Property<T>.less(value: Int): PropertyQueryCondition<T> {
76+
return less(value)
77+
}
78+
3779
// IntArray
3880
/** Creates an "IN (..., ..., ...)" condition for this property. */
3981
infix fun <T> Property<T>.oneOf(value: IntArray): PropertyQueryCondition<T> {

0 commit comments

Comments
 (0)