Mercurial > repos > timpalpant > java_genomics_toolkit
comparison src/edu/unc/genomics/ReadablePathValidator.java @ 2:e16016635b2a
Uploaded
author | timpalpant |
---|---|
date | Mon, 13 Feb 2012 22:12:06 -0500 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
1:a54db233ee3d | 2:e16016635b2a |
---|---|
1 /** | |
2 * | |
3 */ | |
4 package edu.unc.genomics; | |
5 | |
6 import java.nio.file.Files; | |
7 import java.nio.file.Path; | |
8 | |
9 import com.beust.jcommander.IParameterValidator; | |
10 import com.beust.jcommander.ParameterException; | |
11 | |
12 /** | |
13 * @author timpalpant | |
14 * | |
15 */ | |
16 public class ReadablePathValidator implements IParameterValidator { | |
17 | |
18 /* (non-Javadoc) | |
19 * @see com.beust.jcommander.IParameterValidator#validate(java.lang.String, java.lang.String) | |
20 */ | |
21 @Override | |
22 public void validate(String name, String value) throws ParameterException { | |
23 PathConverter converter = new PathConverter(); | |
24 Path p = converter.convert(value); | |
25 if (!Files.isReadable(p)) { | |
26 throw new ParameterException("Parameter " + name + " should be a readable file"); | |
27 } | |
28 } | |
29 | |
30 } |