View Javadoc
1   /**
2    * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
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   * Defines a datatype that supports single String values.
13   * 
14   * @author Brian Remedios
15   */
16  public class StringProperty extends AbstractProperty<String> {
17  
18      public static final PropertyDescriptorFactory FACTORY = new BasicPropertyDescriptorFactory<StringProperty>(
19              String.class) {
20  
21          public StringProperty createWith(Map<String, String> valuesById) {
22              return new StringProperty(nameIn(valuesById), descriptionIn(valuesById), defaultValueIn(valuesById), 0f);
23          }
24      };
25  
26      /**
27       * Constructor for StringProperty.
28       * 
29       * @param theName String
30       * @param theDescription String
31       * @param theDefaultValue String
32       * @param theUIOrder float
33       */
34      public StringProperty(String theName, String theDescription, String theDefaultValue, float theUIOrder) {
35          super(theName, theDescription, theDefaultValue, theUIOrder);
36      }
37  
38      /**
39       * @return String
40       */
41      protected String defaultAsString() {
42          return defaultValue();
43      }
44  
45      /**
46       *
47       * @return Class
48       * @see net.sourceforge.pmd.PropertyDescriptor#type()
49       */
50      public Class<String> type() {
51          return String.class;
52      }
53  
54      /**
55       *
56       * @param valueString String
57       * @return Object
58       * @see net.sourceforge.pmd.PropertyDescriptor#valueFrom(String)
59       */
60      public String valueFrom(String valueString) {
61          return valueString;
62      }
63  }