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 IntegerProperty extends AbstractNumericProperty<Integer> {
17
18 public static final PropertyDescriptorFactory FACTORY = new BasicPropertyDescriptorFactory<IntegerProperty>(Integer.class, numberFieldTypesByKey) {
19
20 public IntegerProperty createWith(Map<String, String> valuesById) {
21 final String[] minMax = minMaxFrom(valuesById);
22 return new IntegerProperty(
23 nameIn(valuesById),
24 descriptionIn(valuesById),
25 Integer.valueOf(minMax[0]),
26 Integer.valueOf(minMax[1]),
27 Integer.valueOf(numericDefaultValueIn(valuesById)),
28 0f);
29 }
30 };
31
32
33
34
35
36
37
38
39
40
41
42
43 public IntegerProperty(String theName, String theDescription, Integer min, Integer max, Integer theDefault, float theUIOrder) {
44 super(theName, theDescription, min, max, theDefault, theUIOrder);
45 }
46
47
48
49
50
51
52
53
54
55
56
57
58
59 public IntegerProperty(String theName, String theDescription, String minStr, String maxStr, String defaultStr, float theUIOrder) {
60 this(theName, theDescription, intFrom(minStr), intFrom(maxStr), intFrom(defaultStr), theUIOrder);
61 }
62
63
64
65
66
67 public static Integer intFrom(String numberString) {
68 return Integer.valueOf(numberString);
69 }
70
71
72
73
74
75 public Class<Integer> type() {
76 return Integer.class;
77 }
78
79
80
81
82
83 protected Object createFrom(String value) {
84 return intFrom(value);
85 }
86 }