Title: DirFileSystemValidator Description: Validator for fully qualified file names where the parent directory must exist but the file is optional
| 368 | * must exist but the file is optional</p> |
| 369 | */ |
| 370 | public static class DirFileSystemValidator implements ArgValueValidator { |
| 371 | |
| 372 | @Override |
| 373 | public void validate(final ConfigurationItem citem) { |
| 374 | final String name = citem.getValue(); |
| 375 | if(name==null || name.trim().isEmpty()) return; |
| 376 | final File f = new File(citem.getValue()).getAbsoluteFile(); |
| 377 | final File dir = f.getParentFile(); |
| 378 | if(dir.exists() && dir.isDirectory()) return; |
| 379 | if(!dir.exists()) throw new IllegalArgumentException("No directory named [" + dir + "] exists. Invalid value for config item:" + citem.getKey()); |
| 380 | if(!dir.isDirectory()) throw new IllegalArgumentException("Specified parent directory [" + dir + "] is not a directory. Invalid value for config item:" + citem.getKey()); |
| 381 | } |
| 382 | |
| 383 | } |
| 384 | |
| 385 | |
| 386 | /** |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…