source: josm/trunk/src/org/openstreetmap/josm/spi/preferences/AbstractSetting.java

Last change on this file was 16553, checked in by Don-vip, 5 years ago

see #19334 - javadoc fixes + protected constructors for abstract classes

  • 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.spi.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 12881 (moved from package {@code org.openstreetmap.josm.data.preferences})
11 */
12public abstract class AbstractSetting<T> implements Setting<T> {
13 protected final T value;
14 protected Long time;
15 protected boolean isNew;
16
17 /**
18 * Constructs a new {@code AbstractSetting} with the given value
19 * @param value The setting value
20 */
21 protected AbstractSetting(T value) {
22 this.value = value;
23 this.time = null;
24 this.isNew = false;
25 }
26
27 @Override
28 public T getValue() {
29 return value;
30 }
31
32 @Override
33 public void setTime(Long time) {
34 this.time = time;
35 }
36
37 @Override
38 public Long getTime() {
39 return this.time;
40 }
41
42 @Override
43 public void setNew(boolean isNew) {
44 this.isNew = isNew;
45 }
46
47 @Override
48 public boolean isNew() {
49 return isNew;
50 }
51
52 @Override
53 public String toString() {
54 return value != null ? value.toString() : "null";
55 }
56
57 @Override
58 public int hashCode() {
59 return Objects.hash(value);
60 }
61
62 @Override
63 public boolean equals(Object obj) {
64 if (this == obj)
65 return true;
66 if (obj == null || getClass() != obj.getClass())
67 return false;
68 return Objects.equals(value, ((AbstractSetting<?>) obj).value);
69 }
70}
Note: See TracBrowser for help on using the repository browser.