public class SimpleOnOffSwitch extends AbstractSimpleSwitch
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.
|
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.
|
getDescription
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
consumeArgument, isOptional, isSwitch, needsArguments
public 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 switch@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 Switch
getShortForms
in class AbstractSimpleSwitch
@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 Switch
getLongForms
in class AbstractSimpleSwitch
@NotNull public java.lang.String getAppearance()
SwitchOrArgument
public void found(char shortSwitch)
Switch
shortSwitch
- short form in which this switch appearedpublic void found(@NotNull java.lang.String longSwitch)
Switch
longSwitch
- long formpublic boolean isSwitchedOn()
true
: switched onfalse
: switched off