Mercurial > repos > timpalpant > java_genomics_toolkit
comparison src/edu/unc/genomics/PositiveIntegerValidator.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 package edu.unc.genomics; | |
2 | |
3 import com.beust.jcommander.IParameterValidator; | |
4 import com.beust.jcommander.ParameterException; | |
5 | |
6 /** | |
7 * @author timpalpant | |
8 * | |
9 */ | |
10 public class PositiveIntegerValidator implements IParameterValidator { | |
11 | |
12 /* (non-Javadoc) | |
13 * @see com.beust.jcommander.IParameterValidator#validate(java.lang.String, java.lang.String) | |
14 */ | |
15 @Override | |
16 public void validate(String name, String value) throws ParameterException { | |
17 int n = Integer.parseInt(value); | |
18 if (n <= 0) { | |
19 throw new ParameterException("Parameter "+name+" must be > 0 (was "+value+")"); | |
20 } | |
21 } | |
22 | |
23 } |