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.
- Version:
- $Id: OptionGroup.java 1749596 2016-06-21 20:27:06Z britter $
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdd the specifiedOption
to this group.getNames()
boolean
Returns 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
-
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.
-
getSelected
- Returns:
- the selected option name
-
setRequired
public void setRequired(boolean required) - Parameters:
required
- specifies if this group is required
-
isRequired
public boolean isRequired()Returns whether this option group is required.- Returns:
- whether this option group is required
-
toString
Returns the stringified version of this OptionGroup.
-