Skip to content

Commit 3f889f0

Browse files
committed
Remove generic type parameter from PropertyQuery
1 parent a5c9fed commit 3f889f0

File tree

3 files changed

+25
-25
lines changed

3 files changed

+25
-25
lines changed

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2017 ObjectBox Ltd. All rights reserved.
2+
* Copyright 2017-2020 ObjectBox Ltd. All rights reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -25,10 +25,10 @@
2525
* (subject to change in a future version).
2626
*/
2727
@SuppressWarnings("WeakerAccess") // WeakerAccess: allow inner class access without accessor
28-
public class PropertyQuery<T> {
29-
final Query<T> query;
28+
public class PropertyQuery {
29+
final Query<?> query;
3030
final long queryHandle;
31-
final Property<T> property;
31+
final Property<?> property;
3232
final int propertyId;
3333

3434
boolean distinct;
@@ -41,7 +41,7 @@ public class PropertyQuery<T> {
4141
String nullValueString;
4242
long nullValueLong;
4343

44-
PropertyQuery(Query<T> query, Property<T> property) {
44+
PropertyQuery(Query<?> query, Property<?> property) {
4545
this.query = query;
4646
queryHandle = query.handle;
4747
this.property = property;
@@ -97,7 +97,7 @@ native String nativeFindString(long handle, long cursorHandle, int propertyId, b
9797
native long nativeCount(long handle, long cursorHandle, int propertyId, boolean distinct);
9898

9999
/** Clears all values (e.g. distinct and null value). */
100-
public PropertyQuery<T> reset() {
100+
public PropertyQuery reset() {
101101
distinct = false;
102102
noCaseIfDistinct = true;
103103
unique = false;
@@ -115,7 +115,7 @@ public PropertyQuery<T> reset() {
115115
* Note: strings default to case-insensitive comparision;
116116
* to change that call {@link #distinct(QueryBuilder.StringOrder)}.
117117
*/
118-
public PropertyQuery<T> distinct() {
118+
public PropertyQuery distinct() {
119119
distinct = true;
120120
return this;
121121
}
@@ -124,7 +124,7 @@ public PropertyQuery<T> distinct() {
124124
* For string properties you can specify {@link io.objectbox.query.QueryBuilder.StringOrder#CASE_SENSITIVE} if you
125125
* want to have case sensitive distinct values (e.g. returning "foo","Foo","FOO" instead of "foo").
126126
*/
127-
public PropertyQuery<T> distinct(QueryBuilder.StringOrder stringOrder) {
127+
public PropertyQuery distinct(QueryBuilder.StringOrder stringOrder) {
128128
if (property.type != String.class) {
129129
throw new RuntimeException("Reserved for string properties, but got " + property);
130130
}
@@ -142,7 +142,7 @@ public PropertyQuery<T> distinct(QueryBuilder.StringOrder stringOrder) {
142142
* <p>
143143
* Will be ignored for find methods returning multiple values, e.g. {@link #findInts()}.
144144
*/
145-
public PropertyQuery<T> unique() {
145+
public PropertyQuery unique() {
146146
unique = true;
147147
return this;
148148
}
@@ -152,7 +152,7 @@ public PropertyQuery<T> unique() {
152152
* However, using this function, you can define an alternative value that will be returned for null values.
153153
* E.g. -1 for ins/longs or "NULL" for strings.
154154
*/
155-
public PropertyQuery<T> nullValue(Object nullValue) {
155+
public PropertyQuery nullValue(Object nullValue) {
156156
//noinspection ConstantConditions Annotation can not enforce non-null.
157157
if (nullValue == null) {
158158
throw new IllegalArgumentException("Null values are not allowed");

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2017-2018 ObjectBox Ltd. All rights reserved.
2+
* Copyright 2017-2020 ObjectBox Ltd. All rights reserved.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -267,8 +267,8 @@ public LazyList<T> findLazy() {
267267
*
268268
* @param property the property for which to return values
269269
*/
270-
public PropertyQuery<T> property(Property<T> property) {
271-
return new PropertyQuery<>(this, property);
270+
public PropertyQuery property(Property<T> property) {
271+
return new PropertyQuery(this, property);
272272
}
273273

274274
<R> R callInReadTx(Callable<R> callable) {

tests/objectbox-java-test/src/test/java/io/objectbox/query/PropertyQueryTest.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ public void testFindStrings_wrongPropertyType() {
161161
@Test
162162
public void testFindString() {
163163
Query<TestEntity> query = box.query().greater(simpleLong, 1002).build();
164-
PropertyQuery<TestEntity> propertyQuery = query.property(simpleString);
164+
PropertyQuery propertyQuery = query.property(simpleString);
165165
assertNull(propertyQuery.findString());
166166
assertNull(propertyQuery.reset().unique().findString());
167167
putTestEntities(5);
@@ -457,7 +457,7 @@ public void testFindShorts_wrongPropertyType() {
457457
@Test
458458
public void testCount() {
459459
Query<TestEntity> query = box.query().build();
460-
PropertyQuery<TestEntity> stringQuery = query.property(simpleString);
460+
PropertyQuery stringQuery = query.property(simpleString);
461461

462462
assertEquals(0, stringQuery.count());
463463

@@ -831,16 +831,16 @@ public void sumDouble_NaN() {
831831
public void testAggregates() {
832832
putTestEntitiesScalars();
833833
Query<TestEntity> query = box.query().less(simpleInt, 2002).build(); // 2 results.
834-
PropertyQuery<TestEntity> booleanQuery = query.property(simpleBoolean);
835-
PropertyQuery<TestEntity> byteQuery = query.property(simpleByte);
836-
PropertyQuery<TestEntity> shortQuery = query.property(simpleShort);
837-
PropertyQuery<TestEntity> intQuery = query.property(simpleInt);
838-
PropertyQuery<TestEntity> longQuery = query.property(simpleLong);
839-
PropertyQuery<TestEntity> floatQuery = query.property(simpleFloat);
840-
PropertyQuery<TestEntity> doubleQuery = query.property(simpleDouble);
841-
PropertyQuery<TestEntity> shortUQuery = query.property(simpleShortU);
842-
PropertyQuery<TestEntity> intUQuery = query.property(simpleIntU);
843-
PropertyQuery<TestEntity> longUQuery = query.property(simpleLongU);
834+
PropertyQuery booleanQuery = query.property(simpleBoolean);
835+
PropertyQuery byteQuery = query.property(simpleByte);
836+
PropertyQuery shortQuery = query.property(simpleShort);
837+
PropertyQuery intQuery = query.property(simpleInt);
838+
PropertyQuery longQuery = query.property(simpleLong);
839+
PropertyQuery floatQuery = query.property(simpleFloat);
840+
PropertyQuery doubleQuery = query.property(simpleDouble);
841+
PropertyQuery shortUQuery = query.property(simpleShortU);
842+
PropertyQuery intUQuery = query.property(simpleIntU);
843+
PropertyQuery longUQuery = query.property(simpleLongU);
844844
// avg
845845
assertEquals(0.5, booleanQuery.avg(), 0.0001);
846846
assertEquals(-37.5, byteQuery.avg(), 0.0001);

0 commit comments

Comments
 (0)