Class NamedOption


  • public final class NamedOption
    extends Object

    Represents an named command line option. The command line specification is determined by the name and type of the option.

    • Name is a single character and is boolean: Short form -n
    • Name is a multiple characters: long form --n
    NamedOptions can be built either by passing a Field containing an Option annotation or by using the builder.

    Three options are predefined and are automatically added to every command line parser:

    • HELP: Shows help if -h or --help is given.
    • CONFIG: Specifies a configuration resource to load when --config is given.
    • DUMP_CONFIG: Shows how the current configuration was created with the lineage of each property when --config-explain is given.

    Author:
    David B. Bracewell
    • Field Detail

      • HELP

        public static final NamedOption HELP
        Shows help if -h or --help is given.
  • Constructor Detail

    • NamedOption

      public NamedOption​(RField field)
      Instantiates a new Named option.
      Parameters:
      field - the field which contains an Option annotation
  • Method Detail

    • getAliasSpecifications

      public String[] getAliasSpecifications()
      Converts the aliases into a specification forms, e.g. with "-" or "--" added.
      Returns:
      the alias specifications
    • getSpecification

      public String getSpecification()
      Gets specification form for the command line.
      Returns:
      the specification form for the command line
    • getValue

      public <T> T getValue()
      Gets the value of the option.
      Type Parameters:
      T - the type parameter
      Returns:
      the value op the option
    • isBoolean

      public boolean isBoolean()
      Determines if the option is a boolean type or not
      Returns:
      True if the option is a boolean type, False otherwise