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