1
2
3
4 package net.sourceforge.pmd.lang.rule.properties;
5
6 import java.util.Map;
7
8
9
10
11
12
13
14
15 public abstract class AbstractDelimitedProperty<T> extends AbstractProperty<T> {
16
17 private char multiValueDelimiter;
18
19 private static final String DELIM_ID = "delimiter";
20
21
22
23
24
25
26
27
28
29 protected AbstractDelimitedProperty(String theName, String theDescription, T theDefault, char delimiter, float theUIOrder) {
30 super(theName, theDescription, theDefault, theUIOrder);
31
32 multiValueDelimiter = delimiter;
33 }
34
35 protected static char delimiterIn(Map<String, String> parameters) {
36 if (!parameters.containsKey(DELIM_ID)) {
37 throw new IllegalArgumentException("missing delimiter value");
38 }
39
40 return parameters.get(DELIM_ID).charAt(0);
41 }
42
43
44
45
46 protected void addAttributesTo(Map<String, String> attributes) {
47 super.addAttributesTo(attributes);
48
49 attributes.put(DELIM_ID, Character.toString(multiValueDelimiter));
50 }
51
52
53
54
55 protected String defaultAsString() {
56 return asDelimitedString(defaultValue(), multiValueDelimiter);
57 }
58
59
60
61
62 protected void multiValueDelimiter(char aDelimiter) {
63 multiValueDelimiter = aDelimiter;
64 }
65
66
67
68
69
70 public char multiValueDelimiter() {
71 return multiValueDelimiter;
72 }
73
74
75
76
77
78 @Override
79 public boolean isMultiValue() {
80 return true;
81 }
82 }