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