File tree Expand file tree Collapse file tree 1 file changed +5
-15
lines changed
objectbox-java/src/main/java/io/objectbox Expand file tree Collapse file tree 1 file changed +5
-15
lines changed Original file line number Diff line number Diff line change @@ -303,26 +303,16 @@ public boolean isEmpty() {
303
303
304
304
/**
305
305
* Returns all stored Objects in this Box.
306
+ * @return since 2.4 the returned list is always mutable (before an empty result list was immutable)
306
307
*/
307
308
public List <T > getAll () {
309
+ ArrayList <T > list = new ArrayList <>();
308
310
Cursor <T > cursor = getReader ();
309
311
try {
310
- T first = cursor .first ();
311
- if (first == null ) {
312
- return Collections .emptyList ();
313
- } else {
314
- ArrayList <T > list = new ArrayList <>();
315
- list .add (first );
316
- while (true ) {
317
- T next = cursor .next ();
318
- if (next != null ) {
319
- list .add (next );
320
- } else {
321
- break ;
322
- }
323
- }
324
- return list ;
312
+ for (T object = cursor .first (); object != null ; object = cursor .next ()) {
313
+ list .add (object );
325
314
}
315
+ return list ;
326
316
} finally {
327
317
releaseReader (cursor );
328
318
}
You can’t perform that action at this time.
0 commit comments