// allows null keys but not null values static B getOrCreate(Map map, A key, Class c) ctex { B b = map.get(key); if (b == null) map.put(key, b = c.newInstance()); ret b; } // f : func -> B static B getOrCreate(Map map, A key, O f) ctex { B b = map.get(key); if (b == null) map.put(key, b = (B) callF(f)); ret b; } static B getOrCreate(IF0 f, Map map, A key) { ret getOrCreate(map, key, f); } static B getOrCreate(Map map, A key, IF0 f) { B b = map.get(key); if (b == null) map.put(key, b = f!); ret b; } static B nuLike getOrCreate(Class c, Map map, A key) { ret getOrCreate(map, key, c); }