]> WPIA git - gigi.git/blobdiff - src/org/cacert/gigi/dbObjects/ObjectCache.java
upd: rename package name and all references to it
[gigi.git] / src / org / cacert / gigi / dbObjects / ObjectCache.java
diff --git a/src/org/cacert/gigi/dbObjects/ObjectCache.java b/src/org/cacert/gigi/dbObjects/ObjectCache.java
deleted file mode 100644 (file)
index 125477d..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-package org.cacert.gigi.dbObjects;
-
-import java.lang.ref.WeakReference;
-import java.util.HashMap;
-import java.util.HashSet;
-
-public class ObjectCache<T extends IdCachable> {
-
-    private final HashMap<Integer, WeakReference<T>> hashmap = new HashMap<>();
-
-    private static final HashSet<ObjectCache<? extends IdCachable>> caches = new HashSet<>();
-
-    protected ObjectCache() {
-        caches.add(this);
-    }
-
-    public T put(T c) {
-        hashmap.put(c.getId(), new WeakReference<T>(c));
-        return c;
-    }
-
-    public T get(int id) {
-        WeakReference<T> res = hashmap.get(id);
-        if (res != null) {
-            return res.get();
-        }
-        return null;
-    }
-
-    public static void clearAllCaches() {
-        for (ObjectCache<? extends IdCachable> objectCache : caches) {
-            objectCache.hashmap.clear();
-        }
-    }
-
-    public void remove(T toRm) {
-        hashmap.remove(toRm.getId());
-    }
-}