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 * @param key the setting key being queried
15 * @return a {@link com.atlassian.fugue.Option.Some Some} containing the String stored against key if one exists (and is a String),
16 * a {@link com.atlassian.fugue.Option#none()} otherwise.
17 * @throws IllegalArgumentException if key is null or longer than {@link UserSettingsService#MAX_KEY_LENGTH} characters.
18 */
19 Option<String> getString(String key);
20
21 /**
22 * @param key the setting key being queried
23 * @return a {@link Option.Some Some} containing the Boolean stored against key if one exists (and is a Boolean),
24 * a {@link com.atlassian.fugue.Option#none()} otherwise.
25 * @throws IllegalArgumentException if key is null or longer than {@link UserSettingsService#MAX_KEY_LENGTH} characters.
26 */
27 Option<Boolean> getBoolean(String key);
28
29 /**
30 * @param key the setting key being queried
31 * @return a {@link Option.Some Some} containing the Long stored against key if one exists (and is a Long),
32 * a {@link com.atlassian.fugue.Option#none()} otherwise.
33 * @throws IllegalArgumentException if key is null or longer than {@link UserSettingsService#MAX_KEY_LENGTH} characters.
34 */
35 Option<Long> getLong(String key);
36
37 /**
38 * @return the set of keys known to this UserSettings
39 */
40 Set<String> getKeys();
41 }