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
|
Rev | Line | |
---|
[9759] | 1 | // License: GPL. For details, see LICENSE file.
|
---|
[12881] | 2 | package org.openstreetmap.josm.spi.preferences;
|
---|
[9759] | 3 |
|
---|
| 4 | import java.util.Objects;
|
---|
| 5 |
|
---|
| 6 | /**
|
---|
| 7 | * Base abstract class of all settings, holding the setting value.
|
---|
| 8 | *
|
---|
| 9 | * @param <T> The setting type
|
---|
[12882] | 10 | * @since 12881 (moved from package {@code org.openstreetmap.josm.data.preferences})
|
---|
[9759] | 11 | */
|
---|
| 12 | public abstract class AbstractSetting<T> implements Setting<T> {
|
---|
| 13 | protected final T value;
|
---|
[9821] | 14 | protected Long time;
|
---|
| 15 | protected boolean isNew;
|
---|
[16553] | 16 |
|
---|
[9759] | 17 | /**
|
---|
| 18 | * Constructs a new {@code AbstractSetting} with the given value
|
---|
| 19 | * @param value The setting value
|
---|
| 20 | */
|
---|
[16553] | 21 | protected AbstractSetting(T value) {
|
---|
[9759] | 22 | this.value = value;
|
---|
[9821] | 23 | this.time = null;
|
---|
| 24 | this.isNew = false;
|
---|
[9759] | 25 | }
|
---|
| 26 |
|
---|
| 27 | @Override
|
---|
| 28 | public T getValue() {
|
---|
| 29 | return value;
|
---|
| 30 | }
|
---|
| 31 |
|
---|
| 32 | @Override
|
---|
[9821] | 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
|
---|
[9759] | 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.