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

public abstract class Option<T> extends Object implements Serializable<T>
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 Details

    • owner

      public final BaseModule owner
      The module that owns this option
    • name

      public final String name
      The name of this option
    • description

      public final String description
      The description of this option
  • Constructor Details

    • Option

      public Option(BaseModule owner, String name, String description)
      Creates a new option
      Parameters:
      owner - The module that owns this option
      name - The name of this option
      description - The description of this option
    • Option

      public Option(BaseModule owner, String name, String description, Option<?> parent)
      Creates a new option with a parent
      Parameters:
      owner - The module that owns this option
      name - The name of this option
      description - The description of this option
      parent - The parent option, or null if this is a root option
  • Method Details

    • getFullName

      public String getFullName()
      Gets the full name of this option
      Returns:
      Name if no parent, ParentName.Name otherwise
    • getValue

      public abstract T getValue()
      Gets the current value of this option
      Returns:
      The current value
    • setValue

      public abstract T setValue(T newValue)
      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

      public abstract T reset()
      Resets this option to its default value
      Returns:
      The default value
    • getParent

      public Option<?> getParent()
      Gets the parent option of this option
      Returns:
      The parent option, or null if this is a root option
    • setParent

      public void setParent(Option<?> parent)
      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