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:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdds the givenOptionto this group.getNames()Gets the names of the options in this group as aCollection.Gets the options in this group as aCollection.Gets the selected option name.booleanTests whether this option group is required.booleanTests whether an option is selected.voidsetRequired(boolean required) Sets whether this group is required.voidsetSelected(Option option) Sets the selected option of this group toname.toString()Returns the stringified version of this OptionGroup.
-
Constructor Details
-
OptionGroup
public OptionGroup()
-
-
Method Details
-
addOption
Adds the givenOptionto this group.- Parameters:
option- the option to add to this group- Returns:
- this option group with the option added
-
getNames
Gets the names of the options in this group as aCollection.- Returns:
- the names of the options in this group as a
Collection.
-
getOptions
Gets the options in this group as aCollection.- Returns:
- the options in this group as a
Collection.
-
getSelected
Gets the selected option name. If the selected option is deprecated no warning is logged.- Returns:
- the selected option name.
-
isRequired
Tests whether this option group is required.- Returns:
- whether this option group is required
-
isSelected
Tests whether an option is selected. If an option is selected and is deprecated no warning is logged.- Returns:
- whether whether an option is selected.
- Since:
- 1.9.0
-
setRequired
Sets whether this group is required.- Parameters:
required- whether this group is required.
-
setSelected
Sets the selected option of this group toname. If the selected option is deprecated no warning is logged.- 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.
-