public class OptionManager
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
private static class |
OptionManager.Entry
Pair of
Option and corresponding documentation string. |
Modifier and Type | Field and Description |
---|---|
private java.util.Map<java.lang.String,OptionManager.Entry> |
options
Maps option name to option instance.
|
private Settings |
settings
The settings instance for loading/saving option values.
|
Constructor and Description |
---|
OptionManager(Settings settings)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
void |
addOption(java.lang.String optionName,
java.lang.String documentation,
Option option)
Adds a new option.
|
CheckBoxOption |
getCheckBoxOption(java.lang.String optionName)
Returns a check box option.
|
void |
loadOptions()
Loads all options' states from the backing settings instance.
|
void |
removeOption(java.lang.String optionName)
Removes an option by name.
|
void |
saveOptions()
Saves all options' states to the backing settings instance.
|
@NotNull private final java.util.Map<java.lang.String,OptionManager.Entry> options
@NotNull private final Settings settings
public OptionManager(@NotNull Settings settings)
settings
- the settings instance for loading/saving option valuespublic void addOption(@NotNull java.lang.String optionName, @NotNull java.lang.String documentation, @NotNull Option option) throws OptionException
optionName
- the option name to adddocumentation
- the documentation string for the settingsoption
- the option to addOptionException
- if the option name is not unique@NotNull public CheckBoxOption getCheckBoxOption(@NotNull java.lang.String optionName) throws OptionException
optionName
- the option name to look upOptionException
- if the option name does not existpublic void loadOptions()
public void removeOption(@NotNull java.lang.String optionName)
optionName
- the option name to removepublic void saveOptions()