• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package org.unicode.cldr.draft;
2 
3 import java.util.HashMap;
4 import java.util.Map;
5 
6 public abstract class MainCache {
7     private static Map<Class<?>, Map<Object, Object>> cache = new HashMap<Class<?>, Map<Object, Object>>();
8 
get(Object key)9     protected synchronized Object get(Object key) {
10         Class<?> classKey = this.getClass();
11         Map<Object, Object> submap = cache.get(classKey);
12         if (submap == null) {
13             cache.put(classKey, submap = new HashMap<Object, Object>());
14         }
15         Object result = submap.get(key);
16         if (result == null) {
17             result = createObject(key);
18             submap.put(key, result);
19         }
20         return result;
21     }
22 
createObject(Object key)23     abstract protected Object createObject(Object key);
24 }
25