Class ConfigOption<T>

Type Parameters:
T - Type of the value of the option
All Implemented Interfaces:
Destructible

public class ConfigOption<T> extends ObservableProperty<T>
Represents an option of the application's configuration.
See Also:
  • Constructor Details

    • ConfigOption

      public ConfigOption(T value)
      Creates a config option without a validator.
      Parameters:
      value - Initial value
    • ConfigOption

      public ConfigOption(T value, Predicate<T> validator) throws IllegalArgumentException
      Creates a config option with a validator.
      Parameters:
      value - Initial value
      Throws:
      IllegalArgumentException - If validator does not evaluate to true for the initial value.
  • Method Details

    • setValue

      public boolean setValue(T value)
      Sets the value of this option.
      Overrides:
      setValue in class MutableProperty<T>
      Parameters:
      value - New value for this option
      Returns:
      true if the value was changed.
    • copyTo

      public void copyTo(ConfigOption<T> otherOption)
      Copies the value of this option to another option.
    • copyFrom

      public void copyFrom(ConfigOption<T> otherOption)
      Copies the value of another option to this option.
    • isValidValue

      public boolean isValidValue(T value)
      Checks whether a value is a valid value for this option.
      Parameters:
      value - Value to check.
      Returns:
      True if the value is valid
    • reset

      public void reset()
      Resets this option to its initial value.