Package org.apache.commons.cli

# Class OptionGroup

java.lang.Object
org.apache.commons.cli.OptionGroup

All Implemented Interfaces:
  `Serializable`

public class OptionGroup extends Object implements Serializable
A group of mutually exclusive options.

See Also:
  - Serialized Form

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `OptionGroup()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `OptionGroup`
  `addOption(Option option)`
  Add the specified `Option` to this group.
  `Collection<String>`
  `getNames()`
  `Collection<Option>`
  `getOptions()`
  `String`
  `getSelected()`
  `boolean`
  `isRequired()`
  Tests whether this option group is required.
  `void`
  `setRequired(boolean required)`
  `void`
  `setSelected(Option option)`
  Sets the selected option of this group to `name`.
  `String`
  `toString()`
  Returns the stringified version of this OptionGroup.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Constructor Details

  - ### OptionGroup

    public OptionGroup()

- ## Method Details

  - ### addOption

    public OptionGroup addOption(Option option)
    Add the specified `Option` to this group.
    Parameters:
      `option` - the option to add to this group
    Returns:
      this option group with the option added

  - ### getNames

    public Collection<String> getNames()
    Returns:
      the names of the options in this group as a `Collection`

  - ### getOptions

    public Collection<Option> getOptions()
    Returns:
      the options in this group as a `Collection`

  - ### getSelected

    public String 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

    public void setSelected(Option option) throws AlreadySelectedException
    Sets the selected option of this group to `name`.
    Parameters:
      `option` - the option that is selected
    Throws:
      `AlreadySelectedException` - if an option from this group has already been selected.

  - ### toString

    public String toString()
    Returns the stringified version of this OptionGroup.
    Overrides:
      `toString` in class `Object`
    Returns:
      the stringified representation of this group