BooleanProperty xref
1 package net.sourceforge.pmd.properties;
2
3
4 /**
5 * Defines a property type that supports Boolean values.
6 *
7 * @author Brian Remedios
8 * @version $Revision$
9 */
10 public class BooleanProperty extends AbstractScalarProperty {
11
12 /**
13 * Constructor for BooleanProperty.
14 * @param theName String
15 * @param theDescription String
16 * @param defaultValue boolean
17 * @param theUIOrder float
18 */
19 public BooleanProperty(String theName, String theDescription, boolean defaultValue, float theUIOrder) {
20 super(theName, theDescription, Boolean.valueOf(defaultValue), theUIOrder);
21 }
22
23 /**
24 * Constructor for BooleanProperty.
25 * @param theName String
26 * @param theDescription String
27 * @param defaultValues boolean[]
28 * @param theUIOrder float
29 * @param theMaxValues int
30 */
31 public BooleanProperty(String theName, String theDescription, boolean[] defaultValues, float theUIOrder, int theMaxValues) {
32 this(theName, theDescription, asBooleans(defaultValues), theUIOrder, theMaxValues);
33
34 }
35
36 /**
37 * Constructor for BooleanProperty.
38 * @param theName String
39 * @param theDescription String
40 * @param defaultValues Boolean[]
41 * @param theUIOrder float
42 * @param theMaxValues int
43 */
44 public BooleanProperty(String theName, String theDescription, Boolean[] defaultValues, float theUIOrder, int theMaxValues) {
45 super(theName, theDescription, defaultValues, theUIOrder);
46
47 maxValueCount(theMaxValues);
48 }
49
50 /**
51 * Method asBooleans.
52 * @param bools boolean[]
53 * @return Boolean[]
54 */
55 private static final Boolean[] asBooleans(boolean[] bools) {
56 Boolean[] booleans = new Boolean[bools.length];
57 for (int i=0; i<bools.length; i++) booleans[i] = Boolean.valueOf(bools[i]);
58 return booleans;
59 }
60
61 /**
62 * Method type.
63 * @return Class
64 * @see net.sourceforge.pmd.PropertyDescriptor#type()
65 */
66 public Class<Boolean> type() {
67 return Boolean.class;
68 }
69
70 /**
71 * Method createFrom.
72 * @param value String
73 * @return Object
74 */
75 protected Object createFrom(String value) {
76 return Boolean.valueOf(value);
77 }
78
79 /**
80 * Method arrayFor.
81 * @param size int
82 * @return Object[]
83 */
84 protected Object[] arrayFor(int size) {
85 return new Boolean[size];
86 }
87 }