de.caff.util.args

## Class SimpleOnSwitch

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

- All Implemented Interfaces:
    Switch, SwitchOrArgument

      public class SimpleOnSwitch
      extends AbstractSwitch

  A boolean switch is for a property that can be switched on.

  So either this switch appears in the command line (switched on), or it does not appear (switched off).

  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
    `SimpleOnSwitch(java.lang.Character shortOn, java.lang.String longOn, 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` | `isSwitchedOn()` Get the value of this switch.
    `boolean` | `isVarLength()` Does this argument or switch have a variable length?

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

    - #### SimpleOnSwitch

          public SimpleOnSwitch(@NotNull
                                java.lang.Character shortOn,
                                @NotNull
                                java.lang.String longOn,
                                @NotNull
                                java.lang.String description)

      Constructor.
      Parameters:
        `shortOn` - the character used for switching on, the switching off character will be automatically done by inverting the case (eg. for `k` it will become `K`), so the character should be in upper or lower case
        `longOn` - the long form used for switching on, the long form for switching off will either be created by prepending `no-` of, if the long form begins with the prefix `with-`, by replacing this prefix with `without-`
        `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

    - #### isSwitchedOn

          public boolean isSwitchedOn()

      Get the value of this switch.
      Returns:
        `true`: switched on
        `false`: switched off