Package dev.boze.api.option
Class ModeOption<T extends Enum<T>>
java.lang.Object
dev.boze.api.option.Option<T>
dev.boze.api.option.ModeOption<T>
- Type Parameters:
T
- The enum type defining the available modes
- All Implemented Interfaces:
Serializable<T>
An option for selecting from a predefined set of modes
ModeOption provides a way to store and modify enum values
The available modes are defined by the enum type parameter
-
Field Summary
Fields inherited from class dev.boze.api.option.Option
description, name, owner
-
Constructor Summary
ConstructorsConstructorDescriptionModeOption
(AddonModule owner, String name, String description, T defaultValue) Creates a new mode option -
Method Summary
Modifier and TypeMethodDescriptionfromJson
(com.google.gson.JsonObject object) Gets the enum class of this mode optionGets the name of the current modegetModes()
Gets a list of all available mode namesgetValue()
Gets the current value of this optionreset()
Resets this option to its default valueSets the value of this optionvoid
setValueByName
(String name) Sets the current mode by namecom.google.gson.JsonObject
toJson()
-
Constructor Details
-
ModeOption
Creates a new mode option- Parameters:
owner
- The module that owns this optionname
- The name of this optiondescription
- The description of this optiondefaultValue
- The initial value and default value
-
-
Method Details
-
getEnumClass
Gets the enum class of this mode option- Returns:
- The enum class
-
getModes
Gets a list of all available mode names- Returns:
- List of mode names
-
getModeName
Gets the name of the current mode- Returns:
- The current mode name
-
getValue
Description copied from class:Option
Gets the current value of this option -
setValue
Description copied from class:Option
Sets the value of this option -
reset
Description copied from class:Option
Resets this option to its default value -
setValueByName
Sets the current mode by nameThe name is case-insensitive
- Parameters:
name
- The name of the mode to set
-
toJson
public com.google.gson.JsonObject toJson()- Returns:
- The object as a JsonObject
-
fromJson
- Parameters:
object
- The JsonObject to deserialize- Returns:
- The deserialized object
-