mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-05-06 08:37:13 +02:00
added asMutableMap method to EnvList to simplify generic environment builder
This commit is contained in:
@@ -35,6 +35,8 @@ package sonia.scm.web.cgi;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.ForwardingMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import sonia.scm.util.Util;
|
||||
@@ -80,6 +82,17 @@ public class EnvList
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns environment as mutable map.
|
||||
*
|
||||
* @return environment as mutable map
|
||||
* @since 1.31
|
||||
*/
|
||||
public Map<String, String> asMutableMap()
|
||||
{
|
||||
return new MapDelegate(envMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
@@ -170,6 +183,65 @@ public class EnvList
|
||||
return result;
|
||||
}
|
||||
|
||||
//~--- inner classes --------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Class description
|
||||
*
|
||||
*
|
||||
* @version Enter version here..., 13/05/15
|
||||
* @author Enter your name here...
|
||||
*/
|
||||
private static class MapDelegate extends ForwardingMap<String, String>
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*
|
||||
* @param delegate
|
||||
*/
|
||||
private MapDelegate(Map<String, String> delegate)
|
||||
{
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
//~--- methods ------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param key
|
||||
* @param value
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String put(String key, String value)
|
||||
{
|
||||
return super.put(key, key.concat("=").concat(Strings.nullToEmpty(value)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
protected Map<String, String> delegate()
|
||||
{
|
||||
return delegate;
|
||||
}
|
||||
|
||||
//~--- fields -------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
private Map<String, String> delegate;
|
||||
}
|
||||
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
|
||||
Reference in New Issue
Block a user