Skip to content

Commit a2e0e12

Browse files
committed
add Box.get(long[] ids)
1 parent 209e9ec commit a2e0e12

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

  • objectbox-java/src/main/java/io/objectbox

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

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,27 @@ public List<T> get(Iterable<Long> ids) {
216216
return list;
217217
}
218218

219+
/**
220+
* Get the stored objects for the given IDs.
221+
*
222+
* @return null if not found
223+
*/
224+
public List<T> get(long[] ids) {
225+
ArrayList<T> list = new ArrayList<>(ids.length);
226+
Cursor<T> reader = getReader();
227+
try {
228+
for (Long id : ids) {
229+
T entity = reader.get(id);
230+
if (entity != null) {
231+
list.add(entity);
232+
}
233+
}
234+
} finally {
235+
releaseReader(reader);
236+
}
237+
return list;
238+
}
239+
219240
/**
220241
* Get the stored objects for the given IDs as a Map with IDs as keys, and entities as values.
221242
* IDs for which no entity is found will be put in the map with null values.
@@ -560,6 +581,21 @@ public void attach(T entity) {
560581
}
561582
}
562583

584+
// Sketching future API extension
585+
private boolean isEmpty() {
586+
return false;
587+
}
588+
589+
// Sketching future API extension
590+
private boolean isChanged(T entity) {
591+
return false;
592+
}
593+
594+
// Sketching future API extension
595+
private boolean putIfChanged(T entity) {
596+
return false;
597+
}
598+
563599
public Class<T> getEntityClass() {
564600
return entityClass;
565601
}

0 commit comments

Comments
 (0)