mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-02 11:35:57 +01:00
refactor: use Map.computeIfAbsent
This commit is contained in:
@@ -35,16 +35,11 @@ package sonia.scm.cli.config;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import javax.xml.bind.annotation.*;
|
||||
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlTransient;
|
||||
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
@@ -148,15 +143,7 @@ public class ScmClientConfig
|
||||
*/
|
||||
public ServerConfig getConfig(String name)
|
||||
{
|
||||
ServerConfig config = serverConfigMap.get(name);
|
||||
|
||||
if (config == null)
|
||||
{
|
||||
config = new ServerConfig();
|
||||
serverConfigMap.put(name, config);
|
||||
}
|
||||
|
||||
return config;
|
||||
return serverConfigMap.computeIfAbsent(name, k -> new ServerConfig());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -211,15 +211,7 @@ public class SVNKitLogger extends SVNDebugLogAdapter
|
||||
*/
|
||||
private Logger getLogger(SVNLogType type)
|
||||
{
|
||||
Logger logger = loggerMap.get(type);
|
||||
|
||||
if (logger == null)
|
||||
{
|
||||
logger = LoggerFactory.getLogger(parseName(type.getName()));
|
||||
loggerMap.put(type, logger);
|
||||
}
|
||||
|
||||
return logger;
|
||||
return loggerMap.computeIfAbsent(type, t -> LoggerFactory.getLogger(parseName(t.getName())));
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
@@ -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 ---------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user