Class ToggleOption

java.lang.Object
dev.boze.api.option.Option<Boolean>
dev.boze.api.option.ToggleOption
All Implemented Interfaces:
Serializable<Boolean>

public class ToggleOption extends Option<Boolean>
A boolean option that can be toggled on or off

ToggleOption provides a simple way to store and modify boolean values

The value can only be true or false
  • Constructor Details

    • ToggleOption

      public ToggleOption(AddonModule owner, String name, String description)
      Creates a new toggle option with a default value of false
      Parameters:
      owner - The module that owns this option
      name - The name of this option
      description - The description of this option
    • ToggleOption

      public ToggleOption(AddonModule owner, String name, String description, boolean value)
      Creates a new toggle option with a specified default value
      Parameters:
      owner - The module that owns this option
      name - The name of this option
      description - The description of this option
      value - The initial value
  • Method Details

    • getValue

      public Boolean getValue()
      Description copied from class: Option
      Gets the current value of this option
      Specified by:
      getValue in class Option<Boolean>
      Returns:
      The current value
    • setValue

      public Boolean setValue(Boolean newValue)
      Description copied from class: Option
      Sets the value of this option
      Specified by:
      setValue in class Option<Boolean>
      Parameters:
      newValue - The new value to set
      Returns:
      The value that was set (may be different from newValue if validation was performed)
    • reset

      public Boolean reset()
      Description copied from class: Option
      Resets this option to its default value
      Specified by:
      reset in class Option<Boolean>
      Returns:
      The default value
    • toJson

      public com.google.gson.JsonObject toJson()
      Returns:
      The object as a JsonObject
    • fromJson

      public Boolean fromJson(com.google.gson.JsonObject object)
      Parameters:
      object - The JsonObject to deserialize
      Returns:
      The deserialized object