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(BaseModule owner, String name, String description, T defaultValue) Creates a new mode optionModeOption(BaseModule owner, String name, String description, T defaultValue, Option<?> parent) Creates a new mode option with a parentModeOption(BaseModule owner, String name, String description, T defaultValue, BooleanSupplier visibility) Creates a new mode option with visibilityModeOption(BaseModule owner, String name, String description, T defaultValue, BooleanSupplier visibility, Option<?> parent) Creates a new mode option with visibility and parent -
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 optionGets the name of the current valuereset()Resets this option to its default valueSets the value of this optionvoidsetValueByName(String name) Sets the current mode by namecom.google.gson.JsonObjecttoJson()Methods inherited from class dev.boze.api.option.Option
getFullName, getParent, isParent, isVisible, setParent, setVisibility
-
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
-
ModeOption
public ModeOption(BaseModule owner, String name, String description, T defaultValue, Option<?> parent) Creates a new mode option with a parent- Parameters:
owner- The module that owns this optionname- The name of this optiondescription- The description of this optiondefaultValue- The initial value and default valueparent- The parent option, or null if this is a root option
-
ModeOption
public ModeOption(BaseModule owner, String name, String description, T defaultValue, BooleanSupplier visibility) Creates a new mode option with visibility- Parameters:
owner- The module that owns this optionname- The name of this optiondescription- The description of this optiondefaultValue- The initial value and default valuevisibility- The visibility supplier for this option
-
ModeOption
public ModeOption(BaseModule owner, String name, String description, T defaultValue, BooleanSupplier visibility, Option<?> parent) Creates a new mode option with visibility and parent- Parameters:
owner- The module that owns this optionname- The name of this optiondescription- The description of this optiondefaultValue- The initial value and default valuevisibility- The visibility supplier for this optionparent- The parent option, or null if this is a root option
-
-
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
-
getValueName
Gets the name of the current value- Returns:
- The current value name
-
getValue
Description copied from class:OptionGets the current value of this option -
setValue
Description copied from class:OptionSets the value of this option -
reset
Description copied from class:OptionResets 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
-