Klasse CmdArgOption.Builder<T>

java.lang.Object
com.github.hypfvieh.cli.parser.CmdArgOption.Builder<T>
Umschließende Klasse:
CmdArgOption<T>

public static final class CmdArgOption.Builder<T> extends Object
Builder for a command-line option.
The builder guarantees the option it builds is valid.
At a minimum an option requires a name.
  • Methodendetails

    • name

      public CmdArgOption.Builder<T> name(String _name)
      Sets option long name.
      Parameter:
      _name - name
      Gibt zurück:
      this
    • shortName

      public CmdArgOption.Builder<T> shortName(Character _name)
      Sets option short name.
      Parameter:
      _name - name
      Gibt zurück:
      this
    • required

      public CmdArgOption.Builder<T> required(boolean _required)
      Sets option to be required or optional.
      Parameter:
      _required - true to be required
      Gibt zurück:
      this
    • required

      public CmdArgOption.Builder<T> required()
      Sets option to be required.
      Gibt zurück:
      this
    • optional

      public CmdArgOption.Builder<T> optional()
      Sets option to be optional.
      Gibt zurück:
      this
    • repeatable

      public CmdArgOption.Builder<T> repeatable(boolean _repeatable)
      Sets option to be repeatable (true) or not (false).
      Parameter:
      _repeatable - true to be repeatable
      Gibt zurück:
      this
    • repeatable

      public CmdArgOption.Builder<T> repeatable()
      Sets option to be repeatable.
      Gibt zurück:
      this
    • defaultValue

      public CmdArgOption.Builder<T> defaultValue(T _defaultValue)
      Sets the option's default value.
      Parameter:
      _defaultValue - value to use, never null
      Gibt zurück:
      this
    • description

      public CmdArgOption.Builder<T> description(String _description)
      Sets the option's description text.
      Parameter:
      _description - text to use
      Gibt zurück:
      this
    • possibleValue

      public CmdArgOption.Builder<T> possibleValue(Map<T,String> _possibleValues)
      Add predefined value and description allowed for this command option.

      The used map implementation provided will define the value order and comparison.
      If you use String as type and you want to allow case-insensitive value comparison
      then use a TreeMap with String.CASE_INSENSITIVE_ORDER comparator.

      Parameter:
      _possibleValues - map with possible values and a description.
      Gibt zurück:
      this
      Seit:
      1.0.4 - 2023-05-12
    • build

      public CmdArgOption<T> build()
      Create the option object based on configuration.
      Gibt zurück:
      CmdArgOption