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