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