static B syncMapGetOrPut(Map map, A key, B value) { if (map == null || key == null) ret value; synchronized(collectionMutex(map)) { B existingValue = map.get(key); if (existingValue != null) ret existingValue; else { map.put(key, value); ret value; } } }