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