refactor: use Map.computeIfAbsent

This commit is contained in:
broDom
2017-07-03 17:10:58 +02:00
parent fb2dfce631
commit 524a5dbb0a
3 changed files with 5 additions and 34 deletions

View File

@@ -81,15 +81,7 @@ public class MapCacheManager
@Override
public synchronized <K, V> MapCache<K, V> getCache(String name)
{
MapCache<K, V> cache = cacheMap.get(name);
if (cache == null)
{
cache = new MapCache<K, V>();
cacheMap.put(name, cache);
}
return cache;
return (MapCache<K, V>) cacheMap.computeIfAbsent(name, k -> new MapCache<K, V>());
}
//~--- fields ---------------------------------------------------------------