Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/util/TripleKeyCache.java')
-rw-r--r--plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/util/TripleKeyCache.java26
1 files changed, 26 insertions, 0 deletions
diff --git a/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/util/TripleKeyCache.java b/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/util/TripleKeyCache.java
new file mode 100644
index 00000000..f1999cae
--- /dev/null
+++ b/plugins/org.eclipse.xtend.backend/src/org/eclipse/xtend/backend/util/TripleKeyCache.java
@@ -0,0 +1,26 @@
+package org.eclipse.xtend.backend.util;
+
+import java.util.HashMap;
+import java.util.Map;
+
+
+/**
+ *
+ * @author Arno Haase (http://www.haase-consulting.com)
+ */
+public abstract class TripleKeyCache<K1, K2, K3, V> {
+ private final Map<Triplet<K1, K2, K3>, V> _cache = new HashMap<Triplet <K1, K2, K3>, V>();
+
+ public V get (K1 key1, K2 key2, K3 key3) {
+ final Triplet<K1, K2, K3> key = new Triplet<K1, K2, K3> (key1, key2, key3);
+
+ if (_cache.containsKey (key))
+ return _cache.get (key);
+
+ final V result = create (key1, key2, key3);
+ _cache.put (key, result);
+ return result;
+ }
+
+ protected abstract V create (K1 key1, K2 key2, K3 key3);
+}

Back to the top