1
2
3
4 package net.sourceforge.pmd.lang.rule.properties;
5
6 import java.io.File;
7 import java.util.Map;
8
9 import net.sourceforge.pmd.PropertyDescriptorFactory;
10 import net.sourceforge.pmd.lang.rule.properties.factories.BasicPropertyDescriptorFactory;
11 import net.sourceforge.pmd.util.StringUtil;
12
13
14
15
16 public class FileProperty extends AbstractProperty<File> {
17
18 public static final PropertyDescriptorFactory FACTORY = new BasicPropertyDescriptorFactory<FileProperty>(File.class) {
19
20 public FileProperty createWith(Map<String, String> valuesById) {
21 return new FileProperty(
22 nameIn(valuesById),
23 descriptionIn(valuesById),
24 null,
25 0f);
26 }
27 };
28
29 public FileProperty(String theName, String theDescription, File theDefault, float theUIOrder) {
30 super(theName, theDescription, theDefault, theUIOrder);
31 }
32
33 public Class<File> type() {
34 return File.class;
35 }
36
37 public File valueFrom(String propertyString) throws IllegalArgumentException {
38
39 return StringUtil.isEmpty(propertyString) ? null : new File(propertyString);
40 }
41
42 @Override
43 protected String defaultAsString() {
44
45 return null;
46 }
47
48 }