public class SimpleOnOffSwitch extends AbstractSwitch
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
LONG_PREFIX_NO |
static java.lang.String |
LONG_PREFIX_WITH |
static java.lang.String |
LONG_PREFIX_WITHOUT |
description, longForm, shortForm| Constructor and Description |
|---|
SimpleOnOffSwitch(java.lang.Character shortOn,
java.lang.String longOn,
boolean defaultValue,
java.lang.String description)
Constructor.
|
| 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.
|
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.
|
boolean |
isSwitchedOn()
Get the value of this switch.
|
boolean |
isVarLength()
Does this argument or switch have a variable length?
|
Switch |
viewOff(java.lang.String description)
View the 'off' state as a single switch state.
|
Switch |
viewOn(java.lang.String description)
View the 'on' state as a single switch state.
|
getDescriptionclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitconsumeArgument, isOptional, isSwitch, needsArgumentspublic static final java.lang.String LONG_PREFIX_WITH
public static final java.lang.String LONG_PREFIX_WITHOUT
public static final java.lang.String LONG_PREFIX_NO
public SimpleOnOffSwitch(@NotNull java.lang.Character shortOn, @NotNull java.lang.String longOn, boolean defaultValue, @NotNull java.lang.String description)
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 caselongOn - 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-defaultValue - default value use when this switch does not appear on the command linedescription - description of this switchpublic boolean isVarLength()
SwitchOrArgumenttrue: this argument or switch consumes the remaining items in the command linefalse: this argument or switch just consumes 1 item (for arguments) or 2 items (for switches) from the command line@NotNull public Switch viewOn(@NotNull java.lang.String description)
description - description of the on state@NotNull public Switch viewOff(@NotNull java.lang.String description)
description - description of the off state@NotNull public java.util.Collection<java.lang.Character> getShortForms()
Switch
If the command line switch is -k, this method
should return a singleton collection with the character
k.
getShortForms in interface SwitchgetShortForms in class AbstractSwitch@NotNull public java.util.Collection<java.lang.String> getLongForms()
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.
getLongForms in interface SwitchgetLongForms in class AbstractSwitch@NotNull public java.lang.String getAppearance()
SwitchOrArgumentpublic void found(char shortSwitch)
SwitchshortSwitch - short form in which this switch appearedpublic void found(@NotNull java.lang.String longSwitch)
SwitchlongSwitch - long formpublic boolean isSwitchedOn()
true: switched onfalse: switched off