Class Setting<T>

java.lang.Object
org.moeaframework.util.mvc.Setting<T>
Type Parameters:
T - the underlying type of the setting
Direct Known Subclasses:
Toggle

public class Setting<T> extends Object
Setting that can fire events when the value changes.
  • Constructor Details

    • Setting

      public Setting(T defaultValue)
      Constructs a setting with the default value.
      Parameters:
      defaultValue - the default value
  • Method Details

    • getDefaultValue

      public T getDefaultValue()
      Returns the default value for this setting.
      Returns:
      the default value
    • set

      public void set(T newValue)
      Sets the value. Any registered listeners are notified if the value changes.
      Parameters:
      newValue - the new value
    • get

      public T get()
      Gets the value. If no value has been set, returns the default value.
      Returns:
      the value
    • addSettingChangedListener

      public void addSettingChangedListener(SettingChangedListener listener)
      Registers a listener to be notified when this setting value changes.
      Parameters:
      listener - the listener to add
    • removeSettingChangedListener

      public void removeSettingChangedListener(SettingChangedListener listener)
      Removes a listener so it is no longer notified of changes.
      Parameters:
      listener - the listener to remove