de.caff.util.args

## Class SingleArgument

- java.lang.Object
- - de.caff.util.args.AbstractBasicArgument
  - - de.caff.util.args.SingleArgument

- All Implemented Interfaces:
    Argument, SwitchOrArgument

      public class SingleArgument
      extends AbstractBasicArgument

  Single required argument.
  Since:
    January 27, 2019
  Author:
    Rammi

- - ### Field Summary

    - ### Fields inherited from interface de.caff.util.args.Argument

      `ARGUMENT_FORMAT`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SingleArgument(java.lang.String name, java.lang.String description)`
    `SingleArgument(java.lang.String name, java.lang.String description, boolean optional)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `consumeArgument(java.lang.String arg)` Read further arguments from the command line.
    `int` | `getMaximalCount()` Get the maximum number of times this argument might appear on the command line.
    `int` | `getMinimalCount()` Get the minimum number of times this argument might appear on the command line.
    `java.lang.String` | `getValue()` Get the value.
    `boolean` | `isOptional()` Default implementation which used the `minimal count` to decide whether this is optional.
    `boolean` | `isVarLength()` Does this argument or switch have a variable length?

    - ### Methods inherited from class de.caff.util.args.AbstractBasicArgument

      `getAppearance, getDescription`

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

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

    - ### Methods inherited from interface de.caff.util.args.Argument

      `isSwitch`

- - ### Constructor Detail

    - #### SingleArgument

          public SingleArgument(@NotNull
                                java.lang.String name,
                                @NotNull
                                java.lang.String description)

    - #### SingleArgument

          public SingleArgument(@NotNull
                                java.lang.String name,
                                @NotNull
                                java.lang.String description,
                                boolean optional)

  - ### Method Detail

    - #### consumeArgument

          public boolean consumeArgument(@NotNull
                                         java.lang.String arg)

      Description copied from interface: `SwitchOrArgument`
      Read further arguments from the command line. The default implementation does not remove any arguments.
      Parameters:
        `arg` - argument
      Returns:
        if more arguments may be consumed

    - #### isVarLength

          public boolean isVarLength()

      Description copied from interface: `SwitchOrArgument`
      Does this argument or switch have a variable length? This is only allowed for the last argument/switch in the command line.
      Returns:
        `true`: this argument or switch consumes the remaining items in the command line
        `false`: this argument or switch just consumes 1 item (for arguments) or 2 items (for switches) from the command line

    - #### getMinimalCount

          public int getMinimalCount()

      Description copied from interface: `Argument`
      Get the minimum number of times this argument might appear on the command line. The default implementation returns `1`.
      Returns:
        minimum number of appearances of this argument

    - #### getMaximalCount

          public int getMaximalCount()

      Description copied from interface: `Argument`
      Get the maximum number of times this argument might appear on the command line. The default implementation returns the value of `Argument.getMinimalCount()`
      Returns:
        maximum number of appearances of this argument, use `Integer.MAX_VALUE` for infinity

    - #### isOptional

          public boolean isOptional()

      Description copied from interface: `Argument`
      Default implementation which used the `minimal count` to decide whether this is optional.
      Returns:
        `true` when minimal count is `0`,
        `false` otherwise

    - #### getValue

          @Nullable
          public java.lang.String getValue()

      Get the value.
      Returns:
        value of this argument