source: josm/trunk/src/org/openstreetmap/josm/data/preferences/AbstractSetting.java@ 12659

Last change on this file since 12659 was 9821, checked in by bastiK, 8 years ago

fixed #12522 - Advanced preferences: display default entries consistently

Saves default preference entries to a cache file (cache/default_preferences.xml), so the list of advanced preferences is filled with all known default values consistently from the start and not gradually as you use different features during a session.

  • Property svn:eol-style set to native
File size: 1.5 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.data.preferences;
3
4import java.util.Objects;
5
6/**
7 * Base abstract class of all settings, holding the setting value.
8 *
9 * @param <T> The setting type
10 * @since 9759
11 */
12public abstract class AbstractSetting<T> implements Setting<T> {
13 protected final T value;
14 protected Long time;
15 protected boolean isNew;
16 /**
17 * Constructs a new {@code AbstractSetting} with the given value
18 * @param value The setting value
19 */
20 public AbstractSetting(T value) {
21 this.value = value;
22 this.time = null;
23 this.isNew = false;
24 }
25
26 @Override
27 public T getValue() {
28 return value;
29 }
30
31 @Override
32 public void setTime(Long time) {
33 this.time = time;
34 }
35
36 @Override
37 public Long getTime() {
38 return this.time;
39 }
40
41 @Override
42 public void setNew(boolean isNew) {
43 this.isNew = isNew;
44 }
45
46 @Override
47 public boolean isNew() {
48 return isNew;
49 }
50
51 @Override
52 public String toString() {
53 return value != null ? value.toString() : "null";
54 }
55
56 @Override
57 public int hashCode() {
58 return Objects.hash(value);
59 }
60
61 @Override
62 public boolean equals(Object obj) {
63 if (this == obj)
64 return true;
65 if (obj == null || getClass() != obj.getClass())
66 return false;
67 return Objects.equals(value, ((AbstractSetting<?>) obj).value);
68 }
69}
Note: See TracBrowser for help on using the repository browser.