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