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

Last change on this file since 9798 was 9759, checked in by Don-vip, 8 years ago

refactor preferences settings classes

  • Property svn:eol-style set to native
File size: 1.0 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 /**
15 * Constructs a new {@code AbstractSetting} with the given value
16 * @param value The setting value
17 */
18 public AbstractSetting(T value) {
19 this.value = value;
20 }
21
22 @Override
23 public T getValue() {
24 return value;
25 }
26
27 @Override
28 public String toString() {
29 return value != null ? value.toString() : "null";
30 }
31
32 @Override
33 public int hashCode() {
34 return Objects.hash(value);
35 }
36
37 @Override
38 public boolean equals(Object obj) {
39 if (this == obj)
40 return true;
41 if (obj == null || getClass() != obj.getClass())
42 return false;
43 return Objects.equals(value, ((AbstractSetting<?>) obj).value);
44 }
45}
Note: See TracBrowser for help on using the repository browser.