Klasse CmdArgOption<T>

java.lang.Object
com.github.hypfvieh.cli.parser.CmdArgOption<T>
Typparameter:
T - data type of the option

public final class CmdArgOption<T> extends Object
Describes a command-line option.
Options are created using the associated CmdArgOption.Builder.

Sample Usage:
CmdArgOption<ITransformer> optImpl = CmdArgOption.builder(ITransformer.class) .name("transformerClass") .description("FQCN of transformer implementation") .required(true) .build(); CommandLine cli = new CommandLine().addOptions(optImpl); // ... cli.parse(args); if (cli.hasOption(optImpl)) { ITransformer transformer = cli.getArg(optImpl); // ... }

Seit:
1.0.0 - 2022-04-19
Autor:
David M., Markus S.
  • Verschachtelte Klassen - Übersicht

    Verschachtelte Klassen
    Modifizierer und Typ
    Klasse
    Beschreibung
    static final class 
    Builder for a command-line option.
    The builder guarantees the option it builds is valid.
    At a minimum an option requires a name.
  • Methodenübersicht

    Modifizierer und Typ
    Methode
    Beschreibung
    Returns a builder for a new option without value (therefore default value not permitted).
    static <T> CmdArgOption.Builder<T>
    builder(Class<T> _dataType)
    Returns a builder for a new option with the specified data type.
    As the data type is specified, the option must have a value (and may have a default value).
    boolean
    equals(Object _obj)
     
    Returns the type of data to create from argument.
    Returns the default value for this option (when option was not set).
    Returns the description text for this option.
    Returns the long name of this option
    A map containing all values (and description) allowed for this option.
    Returns the short name of this option.
    int
     
    boolean
    Flag to signal if the option requires a value.
    boolean
    Flag to signal that this option is optional.
    boolean
    Flag to allow the option to be repeated multiple times.
    boolean
    Flag to signal if this option is required.
     

    Von Klasse geerbte Methoden java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Methodendetails

    • getName

      public String getName()
      Returns the long name of this option
      Gibt zurück:
      String, maybe null or empty
    • getShortName

      public String getShortName()
      Returns the short name of this option.
      Gibt zurück:
      String, maybe empty or null
    • getDescription

      public String getDescription()
      Returns the description text for this option.
      Gibt zurück:
      String, maybe empty or null
    • isRequired

      public boolean isRequired()
      Flag to signal if this option is required.
      Gibt zurück:
      true if required
    • isRepeatable

      public boolean isRepeatable()
      Flag to allow the option to be repeated multiple times.
      Gibt zurück:
      true if repeatable
    • isOptional

      public boolean isOptional()
      Flag to signal that this option is optional.
      Gibt zurück:
      true if optional
    • hasValue

      public boolean hasValue()
      Flag to signal if the option requires a value.
      Gibt zurück:
      true if value required
    • getDefaultValue

      public Object getDefaultValue()
      Returns the default value for this option (when option was not set).
      Gibt zurück:
      default value, maybe null
    • getPossibleValues

      public Map<T,String> getPossibleValues()
      A map containing all values (and description) allowed for this option.
      Gibt zurück:
      Map, maybe empty never null
    • getDataType

      public Class<?> getDataType()
      Returns the type of data to create from argument.
      Gibt zurück:
      class, maybe null
    • hashCode

      public int hashCode()
      Setzt außer Kraft:
      hashCode in Klasse Object
    • equals

      public boolean equals(Object _obj)
      Setzt außer Kraft:
      equals in Klasse Object
    • toString

      public String toString()
      Setzt außer Kraft:
      toString in Klasse Object
    • builder

      public static <T> CmdArgOption.Builder<T> builder(Class<T> _dataType)
      Returns a builder for a new option with the specified data type.
      As the data type is specified, the option must have a value (and may have a default value).
      Typparameter:
      T - data type of the option
      Parameter:
      _dataType - data type of option
      Gibt zurück:
      builder
    • builder

      public static CmdArgOption.Builder<Void> builder()
      Returns a builder for a new option without value (therefore default value not permitted).
      Gibt zurück:
      builder