1 | package org.openstreetmap.josm.gui.preferences.advanced;
|
---|
2 |
|
---|
3 | import org.openstreetmap.josm.data.Preferences;
|
---|
4 | import org.openstreetmap.josm.tools.CheckParameterUtil;
|
---|
5 |
|
---|
6 | /**
|
---|
7 | * Class to store single preference line for the table
|
---|
8 | * @since 6021 : extracted from AdvancedPreference class
|
---|
9 | */
|
---|
10 | public class PrefEntry implements Comparable<PrefEntry> {
|
---|
11 | private String key;
|
---|
12 | private Preferences.Setting value;
|
---|
13 | private Preferences.Setting defaultValue;
|
---|
14 | private boolean isDefault;
|
---|
15 | private boolean changed;
|
---|
16 |
|
---|
17 | public PrefEntry(String key, Preferences.Setting value, Preferences.Setting defaultValue, boolean isDefault) {
|
---|
18 | CheckParameterUtil.ensureParameterNotNull(key);
|
---|
19 | CheckParameterUtil.ensureParameterNotNull(value);
|
---|
20 | CheckParameterUtil.ensureParameterNotNull(defaultValue);
|
---|
21 | this.key = key;
|
---|
22 | this.value = value;
|
---|
23 | this.defaultValue = defaultValue;
|
---|
24 | this.isDefault = isDefault;
|
---|
25 | }
|
---|
26 |
|
---|
27 | public String getKey() {
|
---|
28 | return key;
|
---|
29 | }
|
---|
30 |
|
---|
31 | public Preferences.Setting getValue() {
|
---|
32 | return value;
|
---|
33 | }
|
---|
34 |
|
---|
35 | public Preferences.Setting getDefaultValue() {
|
---|
36 | return defaultValue;
|
---|
37 | }
|
---|
38 |
|
---|
39 | public void setValue(Preferences.Setting value) {
|
---|
40 | this.value = value;
|
---|
41 | changed = true;
|
---|
42 | isDefault = false;
|
---|
43 | }
|
---|
44 |
|
---|
45 | public boolean isDefault() {
|
---|
46 | return isDefault;
|
---|
47 | }
|
---|
48 |
|
---|
49 | public boolean isChanged() {
|
---|
50 | return changed;
|
---|
51 | }
|
---|
52 |
|
---|
53 | public void markAsChanged() {
|
---|
54 | changed = true;
|
---|
55 | }
|
---|
56 |
|
---|
57 | public void reset() {
|
---|
58 | value = defaultValue;
|
---|
59 | changed = true;
|
---|
60 | isDefault = true;
|
---|
61 | }
|
---|
62 |
|
---|
63 | @Override
|
---|
64 | public int compareTo(PrefEntry other) {
|
---|
65 | return key.compareTo(other.key);
|
---|
66 | }
|
---|
67 |
|
---|
68 | @Override
|
---|
69 | public String toString() {
|
---|
70 | return value.toString();
|
---|
71 | }
|
---|
72 | }
|
---|