View Javadoc

1   package com.atlassian.sal.core.pluginsettings;
2   
3   import com.atlassian.sal.api.pluginsettings.PluginSettings;
4   import com.atlassian.sal.core.util.Assert;
5   
6   /**
7    * PluginSettings implementation that delegates to another PluginSettings, adding a prefix to every key passed in
8    */
9   public class PrefixedPluginSettingsDelegate implements PluginSettings
10  {
11      private final String prefix;
12      private final PluginSettings target;
13  
14      public PrefixedPluginSettingsDelegate(String prefix, PluginSettings target)
15      {
16          Assert.notNull(prefix, "Prefix must not be null");
17          Assert.notNull(target, "Target must not be null");
18          this.prefix = prefix;
19          this.target = target;
20      }
21  
22      public Object get(String key)
23      {
24          return target.get(prefix + key);
25      }
26  
27      public Object put(String key, Object value)
28      {
29          return target.put(prefix + key, value);
30      }
31  
32      public Object remove(String key)
33      {
34          return target.remove(prefix + key);
35      }
36  }