01 /**
02 * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
03 */
04 package net.sourceforge.pmd.lang.rule.properties;
05
06 /**
07 * Defines a property type that supports single Boolean values.
08 *
09 * @author Brian Remedios
10 */
11 public class BooleanProperty extends AbstractScalarProperty<Boolean> {
12
13 /**
14 * Constructor for BooleanProperty limited to a single value.
15 *
16 * @param theName String
17 * @param theDescription String
18 * @param defaultValue boolean
19 * @param theUIOrder float
20 */
21 public BooleanProperty(String theName, String theDescription, Boolean defaultValue, float theUIOrder) {
22 super(theName, theDescription, Boolean.valueOf(defaultValue), theUIOrder);
23 }
24
25 /**
26 * Constructor for BooleanProperty limited to a single value.
27 * Converts default argument string into a boolean.
28 *
29 * @param theName String
30 * @param theDescription String
31 * @param defaultBoolStr String
32 * @param theUIOrder float
33 */
34 public BooleanProperty(String theName, String theDescription, String defaultBoolStr, float theUIOrder) {
35 this(theName, theDescription, boolFrom(defaultBoolStr), theUIOrder);
36 }
37
38 /**
39 * @param boolStr String
40 * @return Boolean
41 */
42 private static Boolean boolFrom(String boolStr) {
43 return Boolean.valueOf(boolStr);
44 }
45
46 /**
47 * @return Class
48 * @see net.sourceforge.pmd.PropertyDescriptor#type()
49 */
50 public Class<Boolean> type() {
51 return Boolean.class;
52 }
53
54 /**
55 * @return String
56 */
57 protected String defaultAsString() {
58 return Boolean.toString(defaultValue());
59 }
60
61 /**
62 * Creates and returns a Boolean instance from a raw string
63 *
64 * @param value String
65 * @return Object
66 */
67 protected Object createFrom(String value) {
68 return boolFrom(value);
69 }
70 }
|