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;
10 public class IntegerOption extends Option<Integer, IntegerOption> {
12 public IntegerOption(final String description) {
13 super(description, ParameterCount.ONE);
17 public java.lang.String describeFormat() {
22 public Integer getValue() {
23 if (parameters.size() != 1)
24 throw new RuntimeException("Parameter " + description
25 + " shall have exactly 1 argument.");
26 return Integer.parseInt(parameters.get(0));
30 public boolean isValid(final java.lang.String value) {
32 java.lang.Integer.valueOf(value);
34 } catch (final NumberFormatException e) {