1
2
3
4 package net.sourceforge.pmd.lang.rule.properties;
5
6 import java.util.Map;
7
8 import net.sourceforge.pmd.PropertyDescriptorFactory;
9 import net.sourceforge.pmd.lang.rule.properties.factories.BasicPropertyDescriptorFactory;
10
11
12
13
14
15
16
17 public class IntegerMultiProperty extends AbstractMultiNumericProperty<Integer[]> {
18
19 public static final PropertyDescriptorFactory FACTORY = new BasicPropertyDescriptorFactory<IntegerMultiProperty>(
20 Integer[].class, NUMBER_FIELD_TYPES_BY_KEY) {
21
22 public IntegerMultiProperty createWith(Map<String, String> valuesById) {
23 String[] minMax = minMaxFrom(valuesById);
24 char delimiter = delimiterIn(valuesById, DEFAULT_NUMERIC_DELIMITER);
25 Integer[] defaultValues = integersIn(numericDefaultValueIn(valuesById), delimiter);
26 return new IntegerMultiProperty(nameIn(valuesById), descriptionIn(valuesById), Integer.parseInt(minMax[0]),
27 Integer.parseInt(minMax[1]), defaultValues, 0f);
28 }
29 };
30
31
32
33
34
35
36
37
38
39
40
41
42 public IntegerMultiProperty(String theName, String theDescription, Integer min, Integer max, Integer[] theDefaults,
43 float theUIOrder) {
44 super(theName, theDescription, min, max, theDefaults, theUIOrder);
45 }
46
47
48
49
50
51 public Class<Integer[]> type() {
52 return Integer[].class;
53 }
54
55
56
57
58
59 protected Object createFrom(String value) {
60 return Integer.valueOf(value);
61 }
62
63
64
65
66
67 protected Object[] arrayFor(int size) {
68 return new Integer[size];
69 }
70 }