View Javadoc

1   package com.atlassian.sal.api.usersettings;
2   
3   import com.atlassian.fugue.Option;
4   
5   import java.util.Set;
6   
7   /**
8    * A builder for {@link UserSettings}
9    */
10  public interface UserSettingsBuilder
11  {
12      /**
13       * add an extra entry to the builder, overwriting any existing value stored against key (regardless of type)
14       * @param key the key to store the value against, if null no operation takes place
15       * @param value the non-null String to store
16       * @throws IllegalArgumentException if value is null
17       * @return this builder
18       */
19      UserSettingsBuilder put(String key, String value);
20  
21      /**
22       * add an extra entry to the builder, overwriting any existing value stored against key (regardless of type)
23       * @param key the key to store the value against, if null no operation takes place
24       * @param value the boolean to store
25       * @return this builder
26       */
27      UserSettingsBuilder put(String key, boolean value);
28  
29      /**
30       * add an extra entry to the builder, overwriting any existing value stored against key (regardless of type)
31       * @param key the key to store the value against, if null no operation takes place
32       * @param value the long to store
33       * @return this builder
34       */
35      UserSettingsBuilder put(String key, long value);
36  
37      /**
38       * remove an entry from the builder
39       * @param key the key for the entry to remove
40       * @return this builder
41       */
42      UserSettingsBuilder remove(String key);
43  
44      /**
45       * @param key the setting key being queried
46       * @return a {@link Option.Some Some} containing the value stored against key if one exists, a {@link Option.None}
47       * otherwise. Values can be of type String, Boolean or Long.
48       */
49      Option<Object> get(String key);
50  
51      /**
52       * @return the set of keys known to this UserSettings
53       */
54      Set<String> getKeys();
55  
56      /**
57       *
58       * @return an immutable UserSettings matching the contents of this builder
59       */
60      UserSettings build();
61  }