Package org.apache.commons.cli
Class OptionGroup
java.lang.Object
org.apache.commons.cli.OptionGroup
- All Implemented Interfaces:
Serializable
A group of mutually exclusive options.
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdd the specifiedOption
to this group.getNames()
boolean
Tests whether this option group is required.void
setRequired
(boolean required) void
setSelected
(Option option) Set the selected option of this group toname
.toString()
Returns the stringified version of this OptionGroup.
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDThe serial version UID.- See Also:
-
optionMap
hold the options -
selected
The name of the selected option -
required
private boolean requiredspecified whether this group is required
-
-
Constructor Details
-
OptionGroup
public OptionGroup()
-
-
Method Details
-
addOption
Add the specifiedOption
to this group.- Parameters:
option
- the option to add to this group- Returns:
- this option group with the option added
-
getNames
- Returns:
- the names of the options in this group as a
Collection
-
getOptions
- Returns:
- the options in this group as a
Collection
-
getSelected
- Returns:
- the selected option name
-
isRequired
public boolean isRequired()Tests whether this option group is required.- Returns:
- whether this option group is required
-
setRequired
public void setRequired(boolean required) - Parameters:
required
- specifies if this group is required
-
setSelected
Set the selected option of this group toname
.- Parameters:
option
- the option that is selected- Throws:
AlreadySelectedException
- if an option from this group has already been selected.
-
toString
Returns the stringified version of this OptionGroup.
-