Package dev.boze.api.option
Class Option<T>
java.lang.Object
dev.boze.api.option.Option<T>
- Type Parameters:
T- The type of value stored by this option
- All Implemented Interfaces:
Serializable<T>
- Direct Known Subclasses:
BindOption,ColorOption,ModeOption,ParentOption,SliderOption,ToggleOption
Base class for all module options
Options are used to store configurable values for modules
All options must implement getValue(), setValue(), and reset() methods
Options also implement Serializable to allow for saving/loading from config files
-
Field Summary
FieldsModifier and TypeFieldDescriptionfinal StringThe description of this optionfinal StringThe name of this optionfinal BaseModuleThe module that owns this option -
Constructor Summary
ConstructorsConstructorDescriptionOption(BaseModule owner, String name, String description) Creates a new optionOption(BaseModule owner, String name, String description, Option<?> parent) Creates a new option with a parent -
Method Summary
Modifier and TypeMethodDescriptionGets the full name of this optionOption<?> Gets the parent option of this optionabstract TgetValue()Gets the current value of this optionbooleanisParent()Checks if this option is a parent (has children)abstract Treset()Resets this option to its default valuevoidSets the parent option of this optionabstract TSets the value of this optionMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface dev.boze.api.utility.config.Serializable
fromJson, toJson
-
Field Details
-
owner
The module that owns this option -
name
The name of this option -
description
The description of this option
-
-
Constructor Details
-
Option
Creates a new option- Parameters:
owner- The module that owns this optionname- The name of this optiondescription- The description of this option
-
Option
Creates a new option with a parent- Parameters:
owner- The module that owns this optionname- The name of this optiondescription- The description of this optionparent- The parent option, or null if this is a root option
-
-
Method Details
-
getFullName
Gets the full name of this option- Returns:
- Name if no parent, ParentName.Name otherwise
-
getValue
Gets the current value of this option- Returns:
- The current value
-
setValue
Sets the value of this option- Parameters:
newValue- The new value to set- Returns:
- The value that was set (may be different from newValue if validation was performed)
-
reset
Resets this option to its default value- Returns:
- The default value
-
getParent
Gets the parent option of this option- Returns:
- The parent option, or null if this is a root option
-
setParent
Sets the parent option of this option- Parameters:
parent- the parent option, or null to make this a root option
-
isParent
public boolean isParent()Checks if this option is a parent (has children)- Returns:
- true if this option has children, false otherwise
-