]> WPIA git - gigi.git/blobdiff - src/org/cacert/gigi/dbObjects/ObjectCache.java
refactor: move job to dbObjects Package
[gigi.git] / src / org / cacert / gigi / dbObjects / ObjectCache.java
index e06f84f84a57fd0fde3bafe5d8066b9d6efc08d0..c17dcacff4095ce666bb825a7d1e8394b5b5125b 100644 (file)
@@ -6,9 +6,9 @@ import java.util.HashSet;
 
 public class ObjectCache<T extends IdCachable> {
 
-    HashMap<Integer, WeakReference<T>> hashmap = new HashMap<>();
+    private final HashMap<Integer, WeakReference<T>> hashmap = new HashMap<>();
 
-    private static HashSet<ObjectCache<?>> caches = new HashSet<>();
+    private static final HashSet<ObjectCache<? extends IdCachable>> caches = new HashSet<>();
 
     protected ObjectCache() {
         caches.add(this);
@@ -26,9 +26,13 @@ public class ObjectCache<T extends IdCachable> {
         return null;
     }
 
-    public static void clearAllCashes() {
-        for (ObjectCache<?> objectCache : caches) {
+    public static void clearAllCaches() {
+        for (ObjectCache<? extends IdCachable> objectCache : caches) {
             objectCache.hashmap.clear();
         }
     }
+
+    public void remove(T toRm) {
+        hashmap.remove(toRm);
+    }
 }