Skip to content

Commit 9abe891

Browse files
Add type parameters for all Box<T> usage.
1 parent 615fdc8 commit 9abe891

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ public static boolean isObjectBrowserAvailable() {
169169
private final Map<Class<?>, EntityInfo<?>> propertiesByClass = new HashMap<>();
170170
private final LongHashMap<Class> classByEntityTypeId = new LongHashMap<>();
171171
private final int[] allEntityTypeIds;
172-
private final Map<Class, Box> boxes = new ConcurrentHashMap<>();
172+
private final Map<Class<?>, Box<?>> boxes = new ConcurrentHashMap<>();
173173
private final Set<Transaction> transactions = Collections.newSetFromMap(new WeakHashMap<>());
174174
private final ExecutorService threadPool = new ObjectBoxThreadPool(this);
175175
private final ObjectClassPublisher objectClassPublisher;
@@ -609,7 +609,7 @@ void txCommitted(Transaction tx, @Nullable int[] entityTypeIdsAffected) {
609609
}
610610
}
611611

612-
for (Box box : boxes.values()) {
612+
for (Box<?> box : boxes.values()) {
613613
box.txCommitted(tx);
614614
}
615615

@@ -623,17 +623,17 @@ void txCommitted(Transaction tx, @Nullable int[] entityTypeIdsAffected) {
623623
* <p>
624624
* Creates a Box only once and then always returns the cached instance.
625625
*/
626-
@SuppressWarnings("unchecked")
626+
@SuppressWarnings("unchecked") // Casting is easier than writing a custom Map.
627627
public <T> Box<T> boxFor(Class<T> entityClass) {
628-
Box box = boxes.get(entityClass);
628+
Box<T> box = (Box<T>) boxes.get(entityClass);
629629
if (box == null) {
630630
if (!dbNameByClass.containsKey(entityClass)) {
631631
throw new IllegalArgumentException(entityClass +
632632
" is not a known entity. Please add it and trigger generation again.");
633633
}
634634
// Ensure a box is created just once
635635
synchronized (boxes) {
636-
box = boxes.get(entityClass);
636+
box = (Box<T>) boxes.get(entityClass);
637637
if (box == null) {
638638
box = new Box<>(this, entityClass);
639639
boxes.put(entityClass, box);
@@ -689,7 +689,7 @@ public void runInReadTx(Runnable runnable) {
689689

690690
// TODO That's rather a quick fix, replace with a more general solution
691691
// (that could maybe be a TX listener with abort callback?)
692-
for (Box box : boxes.values()) {
692+
for (Box<?> box : boxes.values()) {
693693
box.readTxFinished(tx);
694694
}
695695

@@ -773,7 +773,7 @@ public <T> T callInReadTx(Callable<T> callable) {
773773

774774
// TODO That's rather a quick fix, replace with a more general solution
775775
// (that could maybe be a TX listener with abort callback?)
776-
for (Box box : boxes.values()) {
776+
for (Box<?> box : boxes.values()) {
777777
box.readTxFinished(tx);
778778
}
779779

@@ -886,7 +886,7 @@ public int cleanStaleReadTransactions() {
886886
* {@link Box#closeThreadResources()} for all initiated boxes ({@link #boxFor(Class)}).
887887
*/
888888
public void closeThreadResources() {
889-
for (Box box : boxes.values()) {
889+
for (Box<?> box : boxes.values()) {
890890
box.closeThreadResources();
891891
}
892892
// activeTx is cleaned up in finally blocks, so do not free them here

0 commit comments

Comments
 (0)