IntegerProperty.java
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 datatype that supports single Integer property values within an upper and lower boundary.
08  
09  @author Brian Remedios
10  */
11 public class IntegerProperty extends AbstractNumericProperty<Integer> {
12 
13   /**
14    * Constructor for IntegerProperty that limits itself to a single value within the specified limits. 
15    
16    @param theName String
17    @param theDescription String
18    @param min Integer
19    @param max Integer
20    @param theDefault Integer
21    @param theUIOrder float
22    @throws IllegalArgumentException
23    */
24   public IntegerProperty(String theName, String theDescription, Integer min, Integer max, Integer theDefault, float theUIOrder) {
25     super(theName, theDescription, min, max, theDefault, theUIOrder);    
26   }
27   
28   /**
29    * Constructor for IntegerProperty that limits itself to a single value within the specified limits. 
30    * Converts string arguments into the Float values.
31    
32    @param theName String
33    @param theDescription String
34    @param minStr String
35    @param maxStr String
36    @param defaultStr String
37    @param theUIOrder
38    @throws IllegalArgumentException
39    */
40   public IntegerProperty(String theName, String theDescription, String minStr, String maxStr, String defaultStr, float theUIOrder) {
41         this(theName, theDescription, intFrom(minStr), intFrom(maxStr), intFrom(defaultStr), theUIOrder);       
42     }
43   
44   /**
45    @param numberString String
46    @return Integer
47    */
48   public static Integer intFrom(String numberString) {
49       return Integer.valueOf(numberString);
50   }
51   
52   /**
53    @return Class
54    @see net.sourceforge.pmd.PropertyDescriptor#type()
55    */
56   public Class<Integer> type() {
57     return Integer.class;
58   }
59 
60   /**
61    @param value String
62    @return Object
63    */
64   protected Object createFrom(String value) {
65     return intFrom(value);
66   }
67 }