Class IntegerOption
java.lang.Object
eu.svjatoslav.commons.cli_helper.parameter_parser.Option<Integer,IntegerOption>
eu.svjatoslav.commons.cli_helper.parameter_parser.parameter.IntegerOption
Represents a command-line option that accepts exactly one parameter interpreted as an integer.
-
Field Summary
Fields inherited from class eu.svjatoslav.commons.cli_helper.parameter_parser.Option
description, mandatory, parameters
-
Constructor Summary
ConstructorsConstructorDescriptionIntegerOption
(String description) Constructs an IntegerOption with exactly one parameter required. -
Method Summary
Methods inherited from class eu.svjatoslav.commons.cli_helper.parameter_parser.Option
addAliases, addParameter, getAliasesAsString, getHelp, isMandatory, isPresent, matchesAlias, noMoreArguments, setMandatory, setPresent
-
Constructor Details
-
IntegerOption
Constructs an IntegerOption with exactly one parameter required.- Parameters:
description
- a brief description of what this option represents.
-
-
Method Details
-
describeFormat
Describes the expected format ("Integer.").- Specified by:
describeFormat
in classOption<Integer,
IntegerOption> - Returns:
- a short string describing the parameter format
-
getValue
Returns the integer value specified by the user.- Specified by:
getValue
in classOption<Integer,
IntegerOption> - Returns:
- the parsed value as the generic type T.
- Throws:
RuntimeException
- if the user did not provide exactly one parameter.
-
isValid
Checks whether the given string can be parsed as an integer.- Specified by:
isValid
in classOption<Integer,
IntegerOption> - Parameters:
value
- the string to validate- Returns:
true
if the string is a valid integer, otherwisefalse
-