Skip to content

Commit 94fac0a

Browse files
committed
Removed deprecated aggregate methods from Query
1 parent 6343f86 commit 94fac0a

File tree

3 files changed

+27
-67
lines changed

3 files changed

+27
-67
lines changed

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

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import io.objectbox.BoxStore;
3131
import io.objectbox.InternalAccess;
3232
import io.objectbox.Property;
33-
import io.objectbox.annotation.apihint.Beta;
3433
import io.objectbox.internal.CallWithHandle;
3534
import io.objectbox.reactive.DataObserver;
3635
import io.objectbox.reactive.DataSubscriptionList;
@@ -379,48 +378,6 @@ public Long call(long cursorHandle) {
379378
});
380379
}
381380

382-
/** @deprecated Use {@link #property(Property)} to get a {@link PropertyQuery} for aggregate functions. */
383-
@Deprecated
384-
public long sum(final Property property) {
385-
return property(property).sum();
386-
}
387-
388-
/** @deprecated Use {@link #property(Property)} to get a {@link PropertyQuery} for aggregate functions. */
389-
@Deprecated
390-
public double sumDouble(final Property property) {
391-
return property(property).sumDouble();
392-
}
393-
394-
/** @deprecated Use {@link #property(Property)} to get a {@link PropertyQuery} for aggregate functions. */
395-
@Deprecated
396-
public long max(final Property property) {
397-
return property(property).max();
398-
}
399-
400-
/** @deprecated Use {@link #property(Property)} to get a {@link PropertyQuery} for aggregate functions. */
401-
@Deprecated
402-
public double maxDouble(final Property property) {
403-
return property(property).maxDouble();
404-
}
405-
406-
/** @deprecated Use {@link #property(Property)} to get a {@link PropertyQuery} for aggregate functions. */
407-
@Deprecated
408-
public long min(final Property property) {
409-
return property(property).min();
410-
}
411-
412-
/** @deprecated Use {@link #property(Property)} to get a {@link PropertyQuery} for aggregate functions. */
413-
@Deprecated
414-
public double minDouble(final Property property) {
415-
return property(property).minDouble();
416-
}
417-
418-
/** @deprecated Use {@link #property(Property)} to get a {@link PropertyQuery} for aggregate functions. */
419-
@Deprecated
420-
public double avg(final Property property) {
421-
return property(property).avg();
422-
}
423-
424381
/**
425382
* Sets a parameter previously given to the {@link QueryBuilder} to a new value.
426383
*/

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,4 +433,31 @@ public void testCount() {
433433
assertEquals(6, stringQuery.distinct().count());
434434
}
435435

436+
437+
@Test
438+
public void testAggregates() {
439+
putTestEntitiesScalars();
440+
Query<TestEntity> query = box.query().less(simpleInt, 2002).build();
441+
PropertyQuery intQuery = query.property(simpleInt);
442+
PropertyQuery floatQuery = query.property(simpleFloat);
443+
assertEquals(2000.5, intQuery.avg(), 0.0001);
444+
assertEquals(2000, intQuery.min(), 0.0001);
445+
assertEquals(400, floatQuery.minDouble(), 0.001);
446+
assertEquals(2001, intQuery.max(), 0.0001);
447+
assertEquals(400.1, floatQuery.maxDouble(), 0.001);
448+
assertEquals(4001, intQuery.sum(), 0.0001);
449+
assertEquals(800.1, floatQuery.sumDouble(), 0.001);
450+
}
451+
452+
@Test
453+
public void testSumDoubleOfFloats() {
454+
TestEntity entity = new TestEntity();
455+
entity.setSimpleFloat(0);
456+
TestEntity entity2 = new TestEntity();
457+
entity2.setSimpleFloat(-2.05f);
458+
box.put(entity, entity2);
459+
double sum = box.query().build().property(simpleFloat).sumDouble();
460+
assertEquals(-2.05, sum, 0.0001);
461+
}
462+
436463
}

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

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -233,30 +233,6 @@ public void testOffsetLimit() {
233233
assertEquals(2005, list.get(1).getSimpleInt());
234234
}
235235

236-
@Test
237-
public void testAggregates() {
238-
putTestEntitiesScalars();
239-
Query<TestEntity> query = box.query().less(simpleInt, 2002).build();
240-
assertEquals(2000.5, query.avg(simpleInt), 0.0001);
241-
assertEquals(2000, query.min(simpleInt), 0.0001);
242-
assertEquals(400, query.minDouble(simpleFloat), 0.001);
243-
assertEquals(2001, query.max(simpleInt), 0.0001);
244-
assertEquals(400.1, query.maxDouble(simpleFloat), 0.001);
245-
assertEquals(4001, query.sum(simpleInt), 0.0001);
246-
assertEquals(800.1, query.sumDouble(simpleFloat), 0.001);
247-
}
248-
249-
@Test
250-
public void testSumDoubleOfFloats() {
251-
TestEntity entity = new TestEntity();
252-
entity.setSimpleFloat(0);
253-
TestEntity entity2 = new TestEntity();
254-
entity2.setSimpleFloat(-2.05f);
255-
box.put(entity, entity2);
256-
double sum = box.query().build().sumDouble(simpleFloat);
257-
assertEquals(-2.05, sum, 0.0001);
258-
}
259-
260236
@Test
261237
public void testString() {
262238
List<TestEntity> entities = putTestEntitiesStrings();

0 commit comments

Comments
 (0)