@@ -136,11 +136,11 @@ public static String getVersionNative() {
136136
137137 /** @return entity ID */
138138 // TODO only use ids once we have them in Java
139- static native int nativeRegisterEntityClass (long store , String entityName , Class entityClass );
139+ static native int nativeRegisterEntityClass (long store , String entityName , Class <?> entityClass );
140140
141141 // TODO only use ids once we have them in Java
142142 static native void nativeRegisterCustomType (long store , int entityId , int propertyId , String propertyName ,
143- Class <? extends PropertyConverter > converterClass , Class customType );
143+ Class <? extends PropertyConverter > converterClass , Class <?> customType );
144144
145145 static native String nativeDiagnose (long store );
146146
@@ -164,12 +164,12 @@ public static boolean isObjectBrowserAvailable() {
164164 private final File directory ;
165165 private final String canonicalPath ;
166166 private final long handle ;
167- private final Map <Class , String > dbNameByClass = new HashMap <>();
168- private final Map <Class , Integer > entityTypeIdByClass = new HashMap <>();
169- private final Map <Class , EntityInfo > propertiesByClass = new HashMap <>();
170- private final LongHashMap <Class > classByEntityTypeId = new LongHashMap <>();
167+ private final Map <Class <?> , String > dbNameByClass = new HashMap <>();
168+ private final Map <Class <?> , Integer > entityTypeIdByClass = new HashMap <>();
169+ private final Map <Class <?> , EntityInfo <?> > propertiesByClass = new HashMap <>();
170+ 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 ;
@@ -191,7 +191,7 @@ public static boolean isObjectBrowserAvailable() {
191191
192192 private final int queryAttempts ;
193193
194- private final TxCallback failedReadTxAttemptCallback ;
194+ private final TxCallback <?> failedReadTxAttemptCallback ;
195195
196196 BoxStore (BoxStoreBuilder builder ) {
197197 context = builder .context ;
@@ -213,14 +213,14 @@ public static boolean isObjectBrowserAvailable() {
213213 }
214214 debugRelations = builder .debugRelations ;
215215
216- for (EntityInfo entityInfo : builder .entityInfoList ) {
216+ for (EntityInfo <?> entityInfo : builder .entityInfoList ) {
217217 try {
218218 dbNameByClass .put (entityInfo .getEntityClass (), entityInfo .getDbName ());
219219 int entityId = nativeRegisterEntityClass (handle , entityInfo .getDbName (), entityInfo .getEntityClass ());
220220 entityTypeIdByClass .put (entityInfo .getEntityClass (), entityId );
221221 classByEntityTypeId .put (entityId , entityInfo .getEntityClass ());
222222 propertiesByClass .put (entityInfo .getEntityClass (), entityInfo );
223- for (Property property : entityInfo .getAllProperties ()) {
223+ for (Property <?> property : entityInfo .getAllProperties ()) {
224224 if (property .customType != null ) {
225225 if (property .converterClass == null ) {
226226 throw new RuntimeException ("No converter class for custom type of " + property );
@@ -333,24 +333,24 @@ private void checkOpen() {
333333 }
334334 }
335335
336- String getDbName (Class entityClass ) {
336+ String getDbName (Class <?> entityClass ) {
337337 return dbNameByClass .get (entityClass );
338338 }
339339
340- Integer getEntityTypeId (Class entityClass ) {
340+ Integer getEntityTypeId (Class <?> entityClass ) {
341341 return entityTypeIdByClass .get (entityClass );
342342 }
343343
344344 @ Internal
345- public int getEntityTypeIdOrThrow (Class entityClass ) {
345+ public int getEntityTypeIdOrThrow (Class <?> entityClass ) {
346346 Integer id = entityTypeIdByClass .get (entityClass );
347347 if (id == null ) {
348348 throw new DbSchemaException ("No entity registered for " + entityClass );
349349 }
350350 return id ;
351351 }
352352
353- public Collection <Class > getAllEntityClasses () {
353+ public Collection <Class <?> > getAllEntityClasses () {
354354 return dbNameByClass .keySet ();
355355 }
356356
@@ -360,17 +360,18 @@ int[] getAllEntityTypeIds() {
360360 }
361361
362362 @ Internal
363- Class getEntityClassOrThrow (int entityTypeId ) {
364- Class clazz = classByEntityTypeId .get (entityTypeId );
363+ Class <?> getEntityClassOrThrow (int entityTypeId ) {
364+ Class <?> clazz = classByEntityTypeId .get (entityTypeId );
365365 if (clazz == null ) {
366366 throw new DbSchemaException ("No entity registered for type ID " + entityTypeId );
367367 }
368368 return clazz ;
369369 }
370370
371+ @ SuppressWarnings ("unchecked" ) // Casting is easier than writing a custom Map.
371372 @ Internal
372- EntityInfo getEntityInfo (Class entityClass ) {
373- return propertiesByClass .get (entityClass );
373+ < T > EntityInfo < T > getEntityInfo (Class < T > entityClass ) {
374+ return ( EntityInfo < T >) propertiesByClass .get (entityClass );
374375 }
375376
376377 /**
@@ -608,7 +609,7 @@ void txCommitted(Transaction tx, @Nullable int[] entityTypeIdsAffected) {
608609 }
609610 }
610611
611- for (Box box : boxes .values ()) {
612+ for (Box <?> box : boxes .values ()) {
612613 box .txCommitted (tx );
613614 }
614615
@@ -622,17 +623,17 @@ void txCommitted(Transaction tx, @Nullable int[] entityTypeIdsAffected) {
622623 * <p>
623624 * Creates a Box only once and then always returns the cached instance.
624625 */
625- @ SuppressWarnings ("unchecked" )
626+ @ SuppressWarnings ("unchecked" ) // Casting is easier than writing a custom Map.
626627 public <T > Box <T > boxFor (Class <T > entityClass ) {
627- Box box = boxes .get (entityClass );
628+ Box < T > box = ( Box < T >) boxes .get (entityClass );
628629 if (box == null ) {
629630 if (!dbNameByClass .containsKey (entityClass )) {
630631 throw new IllegalArgumentException (entityClass +
631632 " is not a known entity. Please add it and trigger generation again." );
632633 }
633634 // Ensure a box is created just once
634635 synchronized (boxes ) {
635- box = boxes .get (entityClass );
636+ box = ( Box < T >) boxes .get (entityClass );
636637 if (box == null ) {
637638 box = new Box <>(this , entityClass );
638639 boxes .put (entityClass , box );
@@ -688,7 +689,7 @@ public void runInReadTx(Runnable runnable) {
688689
689690 // TODO That's rather a quick fix, replace with a more general solution
690691 // (that could maybe be a TX listener with abort callback?)
691- for (Box box : boxes .values ()) {
692+ for (Box <?> box : boxes .values ()) {
692693 box .readTxFinished (tx );
693694 }
694695
@@ -732,7 +733,6 @@ public <T> T callInReadTxWithRetry(Callable<T> callable, int attempts, int initi
732733 cleanStaleReadTransactions ();
733734 }
734735 if (failedReadTxAttemptCallback != null ) {
735- //noinspection unchecked
736736 failedReadTxAttemptCallback .txFinished (null , new DbException (message + " \n " + diagnose , e ));
737737 }
738738 try {
@@ -772,7 +772,7 @@ public <T> T callInReadTx(Callable<T> callable) {
772772
773773 // TODO That's rather a quick fix, replace with a more general solution
774774 // (that could maybe be a TX listener with abort callback?)
775- for (Box box : boxes .values ()) {
775+ for (Box <?> box : boxes .values ()) {
776776 box .readTxFinished (tx );
777777 }
778778
@@ -885,7 +885,7 @@ public int cleanStaleReadTransactions() {
885885 * {@link Box#closeThreadResources()} for all initiated boxes ({@link #boxFor(Class)}).
886886 */
887887 public void closeThreadResources () {
888- for (Box box : boxes .values ()) {
888+ for (Box <?> box : boxes .values ()) {
889889 box .closeThreadResources ();
890890 }
891891 // activeTx is cleaned up in finally blocks, so do not free them here
@@ -972,7 +972,7 @@ public <T> SubscriptionBuilder<Class<T>> subscribe(Class<T> forClass) {
972972 }
973973
974974 @ Internal
975- public Future internalScheduleThread (Runnable runnable ) {
975+ public Future <?> internalScheduleThread (Runnable runnable ) {
976976 return threadPool .submit (runnable );
977977 }
978978
@@ -992,7 +992,7 @@ public int internalQueryAttempts() {
992992 }
993993
994994 @ Internal
995- public TxCallback internalFailedReadTxAttemptCallback () {
995+ public TxCallback <?> internalFailedReadTxAttemptCallback () {
996996 return failedReadTxAttemptCallback ;
997997 }
998998
0 commit comments