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 public class IntegerMultiProperty extends AbstractMultiNumericProperty<Integer[]> {
17
18 public static final PropertyDescriptorFactory FACTORY = new BasicPropertyDescriptorFactory<IntegerMultiProperty>(Integer[].class, numberFieldTypesByKey) {
19
20 public IntegerMultiProperty createWith(Map<String, String> valuesById) {
21 final String[] minMax = minMaxFrom(valuesById);
22 Integer[] defaultValues = integersIn(defaultValueIn(valuesById));
23 return new IntegerMultiProperty(
24 nameIn(valuesById),
25 descriptionIn(valuesById),
26 Integer.parseInt(minMax[0]),
27 Integer.parseInt(minMax[1]),
28 defaultValues,
29 0f
30 );
31 };
32 };
33
34
35
36
37
38
39
40
41
42
43
44 public IntegerMultiProperty(String theName, String theDescription, Integer min, Integer max, Integer[] theDefaults, float theUIOrder) {
45 super(theName, theDescription, min, max, theDefaults, theUIOrder);
46 }
47
48
49
50
51
52 public Class<Integer[]> type() {
53 return Integer[].class;
54 }
55
56
57
58
59
60 protected Object createFrom(String value) {
61 return Integer.valueOf(value);
62 }
63
64
65
66
67
68 protected Object[] arrayFor(int size) {
69 return new Integer[size];
70 }
71 }