Class BooleanOption

java.lang.Object
snaq.util.jclap.Option<Boolean>
snaq.util.jclap.BooleanOption

public final class BooleanOption
extends Option<Boolean>
Implementation of an Option with value of type Boolean (otherwise known as a "flag").
Author:
Giles Winstanley
  • Constructor Details

    • BooleanOption

      public BooleanOption​(String shortName, String longName, String description, int minCount, int maxCount)
      Creates a new BooleanOption instance.
      Parameters:
      shortName - short name of the option (e.g. -?)
      longName - long name of the option (e.g. --help)
      description - helpful description of the option (printed for usage message)
      minCount - minimum number of occurrences required for this option
      maxCount - maximum number of occurrences required for this option
    • BooleanOption

      public BooleanOption​(String shortName, String longName, String description, boolean allowMany)
      Creates a new BooleanOption instance.
      Parameters:
      shortName - short name of the option (e.g. -?)
      longName - long name of the option (e.g. --help)
      description - helpful description of the option (printed for usage message)
      allowMany - whether this option can take more than one value (i.e. be specified more than once)
  • Method Details

    • parseValue

      protected Boolean parseValue​(String arg, Locale locale) throws OptionException
      Parsing of a flag option makes little sense. Possible argument for case of -f=true / --flag=1 / etc.
      Specified by:
      parseValue in class Option<Boolean>
      Parameters:
      arg - string argument from which a value is to be parsed
      locale - locale as specified when initializing the CLAParser instance
      Returns:
      Value of the parsed argument string
      Throws:
      OptionException - if a problem occurs while parsing the argument string
    • getType

      public Class<Boolean> getType()
      Description copied from class: Option
      Returns the class type of value this option can take.
      Specified by:
      getType in class Option<Boolean>
      Returns:
      Class instance