Last change
on this file since 9079 was 9079, checked in by Don-vip, 8 years ago |
update to CheckStyle 6.13
|
-
Property svn:eol-style
set to
native
|
File size:
815 bytes
|
Line | |
---|
1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.data.preferences;
|
---|
3 |
|
---|
4 | import org.openstreetmap.josm.Main;
|
---|
5 |
|
---|
6 | public abstract class ParametrizedEnumProperty<T extends Enum<T>> {
|
---|
7 |
|
---|
8 | private final T defaultValue;
|
---|
9 | private final Class<T> enumClass;
|
---|
10 |
|
---|
11 | public ParametrizedEnumProperty(Class<T> enumClass, T defaultValue) {
|
---|
12 | this.defaultValue = defaultValue;
|
---|
13 | this.enumClass = enumClass;
|
---|
14 | }
|
---|
15 |
|
---|
16 | protected abstract String getKey(String... params);
|
---|
17 |
|
---|
18 | public T get(String... params) {
|
---|
19 | return parse(Main.pref.get(getKey(params), defaultValue.name()));
|
---|
20 | }
|
---|
21 |
|
---|
22 | public boolean put(T value, String... params) {
|
---|
23 | return Main.pref.put(getKey(params), value.name());
|
---|
24 | }
|
---|
25 |
|
---|
26 | protected T parse(String s) {
|
---|
27 | return Enum.valueOf(enumClass, s);
|
---|
28 | }
|
---|
29 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.