java.lang.Object
eu.svjatoslav.commons.cli_helper.parameter_parser.Option<Integer,IntegerOption>
eu.svjatoslav.commons.cli_helper.parameter_parser.parameter.IntegerOption

public class IntegerOption extends Option<Integer,IntegerOption>
Represents a command-line option that accepts exactly one parameter interpreted as an integer.
  • Constructor Details

    • IntegerOption

      public IntegerOption(String description)
      Constructs an IntegerOption with exactly one parameter required.
      Parameters:
      description - a brief description of what this option represents.
  • Method Details

    • describeFormat

      public String describeFormat()
      Describes the expected format ("Integer.").
      Specified by:
      describeFormat in class Option<Integer,IntegerOption>
      Returns:
      a short string describing the parameter format
    • getValue

      public Integer getValue()
      Returns the integer value specified by the user.
      Specified by:
      getValue in class Option<Integer,IntegerOption>
      Returns:
      the parsed value as the generic type T.
      Throws:
      RuntimeException - if the user did not provide exactly one parameter.
    • isValid

      public boolean isValid(String value)
      Checks whether the given string can be parsed as an integer.
      Specified by:
      isValid in class Option<Integer,IntegerOption>
      Parameters:
      value - the string to validate
      Returns:
      true if the string is a valid integer, otherwise false