io.vertx.core.cli

## Class Argument

- java.lang.Object
- - io.vertx.core.cli.Argument

- Direct Known Subclasses:
    TypedArgument

      public class Argument
      extends Object

  Defines a command line argument. Unlike options, argument don't have names and are identified using an index. The first index is 0 (because we are in the computer world).
  Author:
    Clement Escoffier
  See Also:
    `Option`

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected String` | `argName` The argument name used in the usage.
    `static String` | `DEFAULT_ARG_NAME` The default argument name displayed in the usage.
    `protected String` | `defaultValue` The optional default value of this argument.
    `protected String` | `description` The argument description.
    `protected boolean` | `hidden` Whether or not this argument is hidden.
    `protected int` | `index` The argument index.
    `protected boolean` | `multiValued` Whether or not this argument can receive multiple value.
    `protected boolean` | `required` Whether or not this argument is mandatory.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Argument()` Creates a new empty instance of `Argument`.
    `Argument(Argument other)` Creates a new instance of `Argument` by copying `other`.
    `Argument(JsonObject json)` Creates a new instance of `Argument` from the given JSON object.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `ensureValidity()` Checks that the argument configuration is valid.
    `String` | `getArgName()`
    `String` | `getDefaultValue()`
    `String` | `getDescription()`
    `int` | `getIndex()`
    `boolean` | `isHidden()`
    `boolean` | `isMultiValued()`
    `boolean` | `isRequired()`
    `Argument` | `setArgName(String argName)` Sets the argument name of this `Argument`.
    `Argument` | `setDefaultValue(String defaultValue)` Sets the default value of this `Argument`.
    `Argument` | `setDescription(String description)` Sets the description of the `Argument`.
    `Argument` | `setHidden(boolean hidden)` Sets whether or not the current `Argument` is hidden.
    `Argument` | `setIndex(int index)` Sets the argument index.
    `Argument` | `setMultiValued(boolean multiValued)` Sets whether or not the argument can receive several values.
    `Argument` | `setRequired(boolean required)` Sets whether or not the current `Argument` is required.
    `JsonObject` | `toJson()` Exports this `Argument` to its corresponding JSON representation.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### DEFAULT_ARG_NAME

          public static final String DEFAULT_ARG_NAME

      The default argument name displayed in the usage.
      See Also:
        Constant Field Values

    - #### index

          protected int index

      The argument index. Must be positive or null. It is set fo -1 by default to check that the index was set.

    - #### argName

          protected String argName

      The argument name used in the usage.

    - #### description

          protected String description

      The argument description.

    - #### hidden

          protected boolean hidden

      Whether or not this argument is hidden. Hidden argument are not shown in the usage.

    - #### required

          protected boolean required

      Whether or not this argument is mandatory. Mandatory arguments throw a `MissingValueException` if the user command line does not provide a value.

    - #### defaultValue

          protected String defaultValue

      The optional default value of this argument.

    - #### multiValued

          protected boolean multiValued

      Whether or not this argument can receive multiple value. Only the last argument can receive multiple values.

  - ### Constructor Detail

    - #### Argument

          public Argument()

      Creates a new empty instance of `Argument`.

    - #### Argument

          public Argument(Argument other)

      Creates a new instance of `Argument` by copying `other`.
      Parameters:
        `other` - the argument to copy

    - #### Argument

          public Argument(JsonObject json)

      Creates a new instance of `Argument` from the given JSON object.
      Parameters:
        `json` - the json object
      See Also:
        `toJson()`

  - ### Method Detail

    - #### toJson

          public JsonObject toJson()

      Exports this `Argument` to its corresponding JSON representation.
      Returns:
        the json object representing this `Argument`
      See Also:
        `Argument(JsonObject)`

    - #### getArgName

          public String getArgName()

      Returns:
        the arg name, `null` if not defined.

    - #### setArgName

          public Argument setArgName(String argName)

      Sets the argument name of this `Argument`.
      Parameters:
        `argName` - the argument name, must not be `null`
      Returns:
        the current `Argument` instance

    - #### getDescription

          public String getDescription()

      Returns:
        the description, `null` if not defined.

    - #### setDescription

          public Argument setDescription(String description)

      Sets the description of the `Argument`.
      Parameters:
        `description` - the description
      Returns:
        the current `Argument` instance

    - #### isHidden

          public boolean isHidden()

      Returns:
        whether or not the current `Argument` is hidden.

    - #### setHidden

          public Argument setHidden(boolean hidden)

      Sets whether or not the current `Argument` is hidden.
      Parameters:
        `hidden` - enables or disables the visibility of this `Argument`
      Returns:
        the current `Argument` instance

    - #### getIndex

          public int getIndex()

      Returns:
        the argument index.

    - #### setIndex

          public Argument setIndex(int index)

      Sets the argument index.
      Parameters:
        `index` - the index, must not be negative
      Returns:
        the current `Argument` instance

    - #### isRequired

          public boolean isRequired()

      Returns:
        whether or not the current `Argument` is required.

    - #### setRequired

          public Argument setRequired(boolean required)

      Sets whether or not the current `Argument` is required.
      Parameters:
        `required` - `true` to make this argument mandatory, `false` otherwise
      Returns:
        the current `Argument` instance

    - #### getDefaultValue

          public String getDefaultValue()

      Returns:
        the argument default value, `null` if not specified.

    - #### setDefaultValue

          public Argument setDefaultValue(String defaultValue)

      Sets the default value of this `Argument`.
      Parameters:
        `defaultValue` - the default value
      Returns:
        the current `Argument` instance

    - #### isMultiValued

          public boolean isMultiValued()

      Returns:
        whether or not the argument can receive several values.

    - #### setMultiValued

          public Argument setMultiValued(boolean multiValued)

      Sets whether or not the argument can receive several values. Only the last argument can receive several values.
      Parameters:
        `multiValued` - `true` to mark this argument as multi-valued.
      Returns:
        the current `Argument` instance

    - #### ensureValidity

          public void ensureValidity()

      Checks that the argument configuration is valid. This method is mainly made for children classes adding constraint to the configuration. The parser verifies that arguments are valid before starting the parsing.

      If the configuration is not valid, this method throws a `IllegalArgumentException`.

Copyright © 2024 Eclipse. All rights reserved.