1 package eu.svjatoslav.commons.commandline.parameterparser.parameter;
3 import eu.svjatoslav.commons.commandline.parameterparser.ArgumentCount;
4 import eu.svjatoslav.commons.commandline.parameterparser.Parameter;
6 public class IntegerParameter extends Parameter {
8 public IntegerParameter(final String description) {
9 super(description, ArgumentCount.SINGLE);
13 public IntegerParameter addAliases(final String... aliasArray) {
14 super.addAliases(aliasArray);
18 public int getValue() {
19 if (arguments.size() != 1)
20 throw new RuntimeException("Parameter " + description
21 + " shall have exactly 1 argument.");
22 return Integer.parseInt(arguments.get(0));
26 public IntegerParameter setMandatory() {
32 public java.lang.String describeFormat() {
37 public boolean validate(final java.lang.String value) {
39 java.lang.Integer.valueOf(value);
41 } catch (final NumberFormatException e) {