de.caff.util.args

## Class AbstractSwitch

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

- All Implemented Interfaces:
    Switch, SwitchOrArgument
  Direct Known Subclasses:
    AbstractMultipleSwitch, SimpleOnOffSwitch, SimpleOnSwitch, SimpleSwitch, StringArgSwitch

      public abstract class AbstractSwitch
      extends java.lang.Object
      implements Switch

  Basic implementation of a simple switch. This switch just has one short and one long form.
  Since:
    January 27, 2019
  Author:
    Rammi

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected java.lang.String` | `description`
    `protected java.lang.String` | `longForm`
    `protected java.lang.Character` | `shortForm`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `AbstractSwitch(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
    --- | ---
    `java.lang.String` | `getDescription()` Get a short description for this switch.
    `java.util.Collection<java.lang.String>` | `getLongForms()` Get the long forms influencing this switch.
    `java.util.Collection<java.lang.Character>` | `getShortForms()` Get the short one character forms influencing this switch.

    - ### 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, found, found, isOptional, isSwitch, needsArguments`

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

      `getAppearance, isVarLength`

- - ### Field Detail

    - #### shortForm

          @NotNull
          protected final java.lang.Character shortForm

    - #### longForm

          @NotNull
          protected final java.lang.String longForm

    - #### description

          @NotNull
          protected final java.lang.String description

  - ### Constructor Detail

    - #### AbstractSwitch

          protected AbstractSwitch(@NotNull
                                   java.lang.Character shortForm,
                                   @NotNull
                                   java.lang.String longForm,
                                   @NotNull
                                   java.lang.String description)

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

  - ### Method Detail

    - #### getShortForms

          @NotNull
          public java.util.Collection<java.lang.Character> getShortForms()

      Description copied from interface: `Switch`
      Get the short one character forms influencing this switch.

      If the command line switch is `-k`, this method should return a singleton collection with the character `k`.

      Specified by:
        `getShortForms` in interface `Switch`
      Returns:
        short one character forms, may be empty

    - #### getLongForms

          @NotNull
          public java.util.Collection<java.lang.String> getLongForms()

      Description copied from interface: `Switch`
      Get the long forms influencing this switch.

      The return strings must not include the `--` prefix, and have to consist of characters, digits and the minus sign (`-`.

      So if the command line switch is `--kill-all-idiots`, this method should return a singleton collection with the string `kill-all-idiots`.

      Specified by:
        `getLongForms` in interface `Switch`
      Returns:
        long switches. may be empty

    - #### getDescription

          @NotNull
          public java.lang.String getDescription()

      Description copied from interface: `SwitchOrArgument`
      Get a short description for this switch.
      Specified by:
        `getDescription` in interface `SwitchOrArgument`
      Returns:
        short description