de.caff.util.args

## Class SimpleSwitch

- java.lang.Object
- - de.caff.util.args.AbstractSwitch
  - - de.caff.util.args.SimpleSwitch

- All Implemented Interfaces:
    Switch, SwitchOrArgument

      public class SimpleSwitch
      extends AbstractSwitch

  A simple optional switch which either appears on the command line or not.
  Since:
    January 27, 2019
  Author:
    Rammi

- - ### Field Summary

    - ### Fields inherited from class de.caff.util.args.AbstractSwitch

      `description, longForm, shortForm`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SimpleSwitch(java.lang.Character shortForm, java.lang.String longForm, java.lang.String description)` Constructor.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `found(char shortSwitch)` This switch appears in the command line in the given short form.
    `void` | `found(java.lang.String longSwitch)` This switch appears in the command line in the given long form.
    `java.lang.String` | `getAppearance()` Get the appearance of this switch or argument on the command line.
    `boolean` | `hasAppeared()` Has the switch appeared on the command line?
    `boolean` | `isVarLength()` Does this argument or switch have a variable length?
    `void` | `setAppeared(boolean appeared)` Set whether this switch has appeared.

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

      `getDescription, getLongForms, getShortForms`

    - ### 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.Switch

      `consumeArgument, isOptional, isSwitch, needsArguments`

- - ### Constructor Detail

    - #### SimpleSwitch

          public SimpleSwitch(@NotNull
                              java.lang.Character shortForm,
                              @NotNull
                              java.lang.String longForm,
                              @NotNull
                              java.lang.String description)

      Constructor.
      Parameters:
        `shortForm` - short form of switch
        `longForm` - long form of switch
        `description` - description of this switch

  - ### Method Detail

    - #### 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

    - #### getAppearance

          @NotNull
          public java.lang.String getAppearance()

      Description copied from interface: `SwitchOrArgument`
      Get the appearance of this switch or argument on the command line.
      Returns:
        appearance

    - #### found

          public void found(char shortSwitch)

      Description copied from interface: `Switch`
      This switch appears in the command line in the given short form.
      Parameters:
        `shortSwitch` - short form in which this switch appeared

    - #### found

          public void found(@NotNull
                            java.lang.String longSwitch)

      Description copied from interface: `Switch`
      This switch appears in the command line in the given long form.
      Parameters:
        `longSwitch` - long form

    - #### hasAppeared

          public boolean hasAppeared()

      Has the switch appeared on the command line?
      Returns:
        `true`: the switch was included on the command line
        `false`: the switch was not found on the command line

    - #### setAppeared

          public void setAppeared(boolean appeared)

      Set whether this switch has appeared. Usually this should be set automatically via the `found()` methods.
      Parameters:
        `appeared` - `true`: the switch was included on the command line
        `false`: the switch was not found on the command line