2 * Svjatoslav Commons - shared library of common functionality.
3 * Copyright ©2012-2019, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of version 3 of the GNU Lesser General Public License
7 * or later as published by the Free Software Foundation.
10 package eu.svjatoslav.commons.commandline.parameterparser.parameter;
12 import eu.svjatoslav.commons.commandline.parameterparser.ArgumentCount;
13 import eu.svjatoslav.commons.commandline.parameterparser.Parameter;
15 public class IntegerParameter extends Parameter<Integer, IntegerParameter> {
17 public IntegerParameter(final String description) {
18 super(description, ArgumentCount.SINGLE);
22 public java.lang.String describeFormat() {
27 public Integer getValue() {
28 if (arguments.size() != 1)
29 throw new RuntimeException("Parameter " + description
30 + " shall have exactly 1 argument.");
31 return Integer.parseInt(arguments.get(0));
35 public boolean validate(final java.lang.String value) {
37 java.lang.Integer.valueOf(value);
39 } catch (final NumberFormatException e) {