Last change
on this file since 7005 was 6792, checked in by Don-vip, 10 years ago |
Sonar - fix various issues
|
-
Property svn:eol-style
set to
native
|
File size:
1.6 KB
|
Line | |
---|
1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.actions;
|
---|
3 |
|
---|
4 | import org.openstreetmap.josm.actions.search.SearchAction.SearchSetting;
|
---|
5 |
|
---|
6 | public abstract class ActionParameter<T> {
|
---|
7 |
|
---|
8 | private final String name;
|
---|
9 |
|
---|
10 | public ActionParameter(String name) {
|
---|
11 | this.name = name;
|
---|
12 | }
|
---|
13 |
|
---|
14 | public String getName() {
|
---|
15 | return name;
|
---|
16 | }
|
---|
17 |
|
---|
18 | public abstract Class<T> getType();
|
---|
19 |
|
---|
20 | public abstract String writeToString(T value);
|
---|
21 |
|
---|
22 | public abstract T readFromString(String s);
|
---|
23 |
|
---|
24 | public static class StringActionParameter extends ActionParameter<String> {
|
---|
25 |
|
---|
26 | public StringActionParameter(String name) {
|
---|
27 | super(name);
|
---|
28 | }
|
---|
29 |
|
---|
30 | @Override
|
---|
31 | public Class<String> getType() {
|
---|
32 | return String.class;
|
---|
33 | }
|
---|
34 |
|
---|
35 | @Override
|
---|
36 | public String readFromString(String s) {
|
---|
37 | return s;
|
---|
38 | }
|
---|
39 |
|
---|
40 | @Override
|
---|
41 | public String writeToString(String value) {
|
---|
42 | return value;
|
---|
43 | }
|
---|
44 | }
|
---|
45 |
|
---|
46 | public static class SearchSettingsActionParameter extends ActionParameter<SearchSetting> {
|
---|
47 |
|
---|
48 | public SearchSettingsActionParameter(String name) {
|
---|
49 | super(name);
|
---|
50 | }
|
---|
51 |
|
---|
52 | @Override
|
---|
53 | public Class<SearchSetting> getType() {
|
---|
54 | return SearchSetting.class;
|
---|
55 | }
|
---|
56 |
|
---|
57 | @Override
|
---|
58 | public SearchSetting readFromString(String s) {
|
---|
59 | return SearchSetting.readFromString(s);
|
---|
60 | }
|
---|
61 |
|
---|
62 | @Override
|
---|
63 | public String writeToString(SearchSetting value) {
|
---|
64 | if (value == null)
|
---|
65 | return "";
|
---|
66 | return value.writeToString();
|
---|
67 | }
|
---|
68 | }
|
---|
69 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.