Skip to content

Commit 703b9e0

Browse files
Add type parameters in ToMany.
1 parent ee67f28 commit 703b9e0

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ Class<?> getEntityClassOrThrow(int entityTypeId) {
368368
return clazz;
369369
}
370370

371-
@SuppressWarnings("unchecked") // Shortcut to implementing a Map<Class<? extends B>, B>.
371+
@SuppressWarnings("unchecked") // Casting is easier than writing a custom Map.
372372
@Internal
373373
<T> EntityInfo<T> getEntityInfo(Class<T> entityClass) {
374374
return (EntityInfo<T>) propertiesByClass.get(entityClass);

objectbox-java/src/main/java/io/objectbox/relation/ToMany.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@
6161
*
6262
* @param <TARGET> Object type (entity).
6363
*/
64-
@SuppressWarnings("unchecked")
6564
public class ToMany<TARGET> implements List<TARGET>, Serializable {
6665
private static final long serialVersionUID = 2367317778240689006L;
6766
private final static Integer ONE = Integer.valueOf(1);
@@ -85,7 +84,7 @@ public class ToMany<TARGET> implements List<TARGET>, Serializable {
8584
List<TARGET> entitiesToRemoveFromDb;
8685

8786
transient private BoxStore boxStore;
88-
transient private Box entityBox;
87+
transient private Box<Object> entityBox;
8988
transient private volatile Box<TARGET> targetBox;
9089
transient private boolean removeFromTargetBox;
9190
transient private Comparator<TARGET> comparator;
@@ -295,12 +294,12 @@ public synchronized void clear() {
295294
entitiesToClear.clear();
296295
}
297296

298-
Map setToClear = entitiesAdded;
297+
Map<TARGET, Boolean> setToClear = entitiesAdded;
299298
if (setToClear != null) {
300299
setToClear.clear();
301300
}
302301

303-
Map entityCountsToClear = this.entityCounts;
302+
Map<TARGET, Integer> entityCountsToClear = this.entityCounts;
304303
if (entityCountsToClear != null) {
305304
entityCountsToClear.clear();
306305
}
@@ -557,7 +556,7 @@ public void applyChangesToDb() {
557556
if (internalCheckApplyToDbRequired()) {
558557
// We need a TX because we use two writers and both must use same TX (without: unchecked, SIGSEGV)
559558
boxStore.runInTx(() -> {
560-
Cursor sourceCursor = InternalAccess.getActiveTxCursor(entityBox);
559+
Cursor<Object> sourceCursor = InternalAccess.getActiveTxCursor(entityBox);
561560
Cursor<TARGET> targetCursor = InternalAccess.getActiveTxCursor(targetBox);
562561
internalApplyToDb(sourceCursor, targetCursor);
563562
});
@@ -782,7 +781,7 @@ private boolean prepareToOneBacklinkEntitiesForDb(long entityId, IdGetter<TARGET
782781
* Convention: {@link #internalCheckApplyToDbRequired()} must be called before this call as it prepares .
783782
*/
784783
@Internal
785-
public void internalApplyToDb(Cursor sourceCursor, Cursor<TARGET> targetCursor) {
784+
public void internalApplyToDb(Cursor<?> sourceCursor, Cursor<TARGET> targetCursor) {
786785
TARGET[] toRemoveFromDb;
787786
TARGET[] toPut;
788787
TARGET[] addedStandalone = null;
@@ -848,7 +847,7 @@ public void internalApplyToDb(Cursor sourceCursor, Cursor<TARGET> targetCursor)
848847
/**
849848
* The list of removed entities may contain non-persisted entities, which will be ignored (removed from the list).
850849
*/
851-
private void removeStandaloneRelations(Cursor cursor, long sourceEntityId, List<TARGET> removed,
850+
private void removeStandaloneRelations(Cursor<?> cursor, long sourceEntityId, List<TARGET> removed,
852851
IdGetter<TARGET> targetIdGetter) {
853852
Iterator<TARGET> iterator = removed.iterator();
854853
while (iterator.hasNext()) {
@@ -868,7 +867,7 @@ private void removeStandaloneRelations(Cursor cursor, long sourceEntityId, List<
868867
}
869868

870869
/** The target array may not contain non-persisted entities. */
871-
private void addStandaloneRelations(Cursor cursor, long sourceEntityId, TARGET[] added,
870+
private void addStandaloneRelations(Cursor<?> cursor, long sourceEntityId, TARGET[] added,
872871
IdGetter<TARGET> targetIdGetter) {
873872
int length = added.length;
874873
long[] targetIds = new long[length];

0 commit comments

Comments
 (0)