|
Last change
on this file since 12881 was 12881, checked in by bastiK, 8 years ago |
|
see #15229 - move remaining classes to spi.preferences package, to make it self-contained
- extract event listener classes from
Preferences (duplicated, for smooth transition)
- move
*Setting classes
|
-
Property svn:eol-style
set to
native
|
|
File size:
1.5 KB
|
| Line | |
|---|
| 1 | // License: GPL. For details, see LICENSE file.
|
|---|
| 2 | package org.openstreetmap.josm.spi.preferences;
|
|---|
| 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
|
|---|
| 10 | * @since xxx (moved from package {@code org.openstreetmap.josm.data.preferences})
|
|---|
| 11 | */
|
|---|
| 12 | public 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.