2 * Svjatoslav Commons - shared library of common functionality. Author: Svjatoslav Agejenko.
3 * This project is released under Creative Commons Zero (CC0) license.
5 package eu.svjatoslav.commons.cli_helper.parameter_parser.parameter;
7 import eu.svjatoslav.commons.cli_helper.parameter_parser.ParameterCount;
8 import eu.svjatoslav.commons.cli_helper.parameter_parser.Option;
11 * This class represents commandline option which accepts exactly one parameter
12 * which is an integer.
14 public class IntegerOption extends Option<Integer, IntegerOption> {
16 public IntegerOption(final String description) {
17 super(description, ParameterCount.ONE);
21 public java.lang.String describeFormat() {
26 public Integer getValue() {
27 if (parameters.size() != 1)
28 throw new RuntimeException("Parameter " + description
29 + " shall have exactly 1 argument.");
30 return Integer.parseInt(parameters.get(0));
34 public boolean isValid(final java.lang.String value) {
36 java.lang.Integer.valueOf(value);
38 } catch (final NumberFormatException e) {