@@ -181,7 +181,7 @@ public PropertyQuery nullValue(Object nullValue) {
181
181
* <p>
182
182
* Note: results are not guaranteed to be in any particular order.
183
183
* <p>
184
- * See also: {@link #distinct}, {@link #distinct(QueryBuilder.StringOrder)}
184
+ * See also: {@link #distinct() }, {@link #distinct(QueryBuilder.StringOrder)}
185
185
*
186
186
* @return Found strings
187
187
*/
@@ -204,7 +204,7 @@ public String[] call() {
204
204
* <p>
205
205
* Note: results are not guaranteed to be in any particular order.
206
206
* <p>
207
- * See also: {@link #distinct}
207
+ * See also: {@link #distinct() }
208
208
*
209
209
* @return Found longs
210
210
*/
@@ -225,7 +225,7 @@ public long[] call() {
225
225
* <p>
226
226
* Note: results are not guaranteed to be in any particular order.
227
227
* <p>
228
- * See also: {@link #distinct}
228
+ * See also: {@link #distinct() }
229
229
*/
230
230
public int [] findInts () {
231
231
return (int []) query .callInReadTx (new Callable <int []>() {
@@ -244,7 +244,7 @@ public int[] call() {
244
244
* <p>
245
245
* Note: results are not guaranteed to be in any particular order.
246
246
* <p>
247
- * See also: {@link #distinct}
247
+ * See also: {@link #distinct() }
248
248
*/
249
249
public short [] findShorts () {
250
250
return (short []) query .callInReadTx (new Callable <short []>() {
@@ -263,7 +263,7 @@ public short[] call() {
263
263
* <p>
264
264
* Note: results are not guaranteed to be in any particular order.
265
265
* <p>
266
- * See also: {@link #distinct}
266
+ * See also: {@link #distinct() }
267
267
*/
268
268
public char [] findChars () {
269
269
return (char []) query .callInReadTx (new Callable <char []>() {
@@ -299,7 +299,7 @@ public byte[] call() {
299
299
* <p>
300
300
* Note: results are not guaranteed to be in any particular order.
301
301
* <p>
302
- * See also: {@link #distinct}
302
+ * See also: {@link #distinct() }
303
303
*/
304
304
public float [] findFloats () {
305
305
return (float []) query .callInReadTx (new Callable <float []>() {
@@ -318,7 +318,7 @@ public float[] call() {
318
318
* <p>
319
319
* Note: results are not guaranteed to be in any particular order.
320
320
* <p>
321
- * See also: {@link #distinct}
321
+ * See also: {@link #distinct() }
322
322
*/
323
323
public double [] findDoubles () {
324
324
return (double []) query .callInReadTx (new Callable <double []>() {
@@ -383,13 +383,16 @@ public Double findDouble() {
383
383
return (Double ) findNumber ();
384
384
}
385
385
386
-
387
386
/**
388
387
* Sums up all values for the given property over all Objects matching the query.
389
- * <p>
390
- * Note: throws {@link io.objectbox.exception.NumericOverflowException NumericOverflowException} if
391
- * the sum exceeds the numbers {@link Long} can represent. This is different from Java arithmetic
392
- * where it would "wrap around" (e.g. max. value + 1 = min. value).
388
+ *
389
+ * Note: this method is not recommended for properties of type long unless you know the contents of the DB not to
390
+ * overflow. Use {@link #sumDouble()} instead if you cannot guarantee the sum to be in the long value range.
391
+ *
392
+ * @return 0 in case no elements matched the query
393
+ * @throws io.objectbox.exception.NumericOverflowException if the sum exceeds the numbers {@link Long} can
394
+ * represent.
395
+ * This is different from Java arithmetic where it would "wrap around" (e.g. max. value + 1 = min. value).
393
396
*/
394
397
public long sum () {
395
398
return (Long ) query .callInReadTx (new Callable <Long >() {
@@ -400,7 +403,13 @@ public Long call() {
400
403
});
401
404
}
402
405
403
- /** Sums up all values for the given property over all Objects matching the query. */
406
+ /**
407
+ * Sums up all values for the given property over all Objects matching the query.
408
+ *
409
+ * Note: for integer types int and smaller, {@link #sum()} is usually preferred for sums.
410
+ *
411
+ * @return 0 in case no elements matched the query
412
+ */
404
413
public double sumDouble () {
405
414
return (Double ) query .callInReadTx (new Callable <Double >() {
406
415
@ Override
@@ -410,7 +419,11 @@ public Double call() {
410
419
});
411
420
}
412
421
413
- /** Finds the maximum value for the given property over all Objects matching the query. */
422
+ /**
423
+ * Finds the maximum value for the given property over all Objects matching the query.
424
+ *
425
+ * @return Long.MIN_VALUE in case no elements matched the query
426
+ */
414
427
public long max () {
415
428
return (Long ) query .callInReadTx (new Callable <Long >() {
416
429
@ Override
@@ -420,7 +433,11 @@ public Long call() {
420
433
});
421
434
}
422
435
423
- /** Finds the maximum value for the given property over all Objects matching the query. */
436
+ /**
437
+ * Finds the maximum value for the given property over all Objects matching the query.
438
+ *
439
+ * @return NaN in case no elements matched the query
440
+ */
424
441
public double maxDouble () {
425
442
return (Double ) query .callInReadTx (new Callable <Double >() {
426
443
@ Override
@@ -430,7 +447,11 @@ public Double call() {
430
447
});
431
448
}
432
449
433
- /** Finds the minimum value for the given property over all Objects matching the query. */
450
+ /**
451
+ * Finds the minimum value for the given property over all Objects matching the query.
452
+ *
453
+ * @return Long.MAX_VALUE in case no elements matched the query
454
+ */
434
455
public long min () {
435
456
return (Long ) query .callInReadTx (new Callable <Long >() {
436
457
@ Override
@@ -440,7 +461,11 @@ public Long call() {
440
461
});
441
462
}
442
463
443
- /** Finds the minimum value for the given property over all Objects matching the query. */
464
+ /**
465
+ * Finds the minimum value for the given property over all objects matching the query.
466
+ *
467
+ * @return NaN in case no elements matched the query
468
+ */
444
469
public double minDouble () {
445
470
return (Double ) query .callInReadTx (new Callable <Double >() {
446
471
@ Override
@@ -454,6 +479,8 @@ public Double call() {
454
479
* Calculates the average of all values for the given number property over all Objects matching the query.
455
480
* <p>
456
481
* For integer properties you can also use {@link #avgLong()}.
482
+ *
483
+ * @return NaN in case no elements matched the query
457
484
*/
458
485
public double avg () {
459
486
return (Double ) query .callInReadTx (new Callable <Double >() {
@@ -468,6 +495,8 @@ public Double call() {
468
495
* Calculates the average of all values for the given integer property over all Objects matching the query.
469
496
* <p>
470
497
* For floating-point properties use {@link #avg()}.
498
+ *
499
+ * @return 0 in case no elements matched the query
471
500
*/
472
501
public long avgLong () {
473
502
return (Long ) query .callInReadTx (new Callable <Long >() {
@@ -478,6 +507,11 @@ public Long call() {
478
507
});
479
508
}
480
509
510
+ /**
511
+ * The count of non-null values.
512
+ * <p>
513
+ * See also: {@link #distinct()}
514
+ */
481
515
public long count () {
482
516
return (Long ) query .callInReadTx (new Callable <Long >() {
483
517
@ Override
0 commit comments