1 package com.atlassian.sal.api.usersettings;
2
3 import com.atlassian.fugue.Option;
4
5 import java.util.Set;
6
7 /**
8 * An immutable container of user-specific settings.
9 *
10 * Key is global - two values of different types can _not_ be stored against a common key.
11 */
12 public interface UserSettings
13 {
14 /**
15 * @param key the setting key being queried
16 * @return a {@link com.atlassian.fugue.Option.Some Some} containing the String stored against key if one exists (and is a String),
17 * a {@link com.atlassian.fugue.Option#none()} otherwise.
18 * @throws IllegalArgumentException if key is null or longer than {@link UserSettingsService#MAX_KEY_LENGTH} characters.
19 */
20 Option<String> getString(String key);
21
22 /**
23 * @param key the setting key being queried
24 * @return a {@link Option.Some Some} containing the Boolean stored against key if one exists (and is a Boolean),
25 * a {@link com.atlassian.fugue.Option#none()} otherwise.
26 * @throws IllegalArgumentException if key is null or longer than {@link UserSettingsService#MAX_KEY_LENGTH} characters.
27 */
28 Option<Boolean> getBoolean(String key);
29
30 /**
31 * @param key the setting key being queried
32 * @return a {@link Option.Some Some} containing the Long stored against key if one exists (and is a Long),
33 * a {@link com.atlassian.fugue.Option#none()} otherwise.
34 * @throws IllegalArgumentException if key is null or longer than {@link UserSettingsService#MAX_KEY_LENGTH} characters.
35 */
36 Option<Long> getLong(String key);
37
38 /**
39 * @return the set of keys known to this UserSettings
40 */
41 Set<String> getKeys();
42 }