org.eclipse.handly.ui.preference

## Class AbstractPreference

- java.lang.Object
- - org.eclipse.handly.ui.preference.AbstractPreference

- All Implemented Interfaces:
    IPreference
  Direct Known Subclasses:
    BooleanPreference, DoublePreference, FloatPreference, IntPreference, LongPreference, StringPreference

      public abstract class AbstractPreference
      extends java.lang.Object
      implements IPreference

  An abstract base implementation of a preference. The preference is stored in an `IPreferenceStore`.
  Restriction:
    This class is not intended to be subclassed by clients.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractPreference(java.lang.String name, org.eclipse.jface.preference.IPreferenceStore store)` Creates a new preference with the given name and the given store.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addListener(IPreferenceListener listener)` Adds the given listener for value change events to this preference.
    `java.lang.String` | `getName()` Returns the name of this preference.
    `org.eclipse.jface.preference.IPreferenceStore` | `getStore()` Returns the store for this preference.
    `boolean` | `isDefault()` Returns whether the current value of this preference has the default value.
    `void` | `removeListener(IPreferenceListener listener)` Removes the given value change listener from this preference.
    `void` | `setToDefault()` Sets the current value of this preference back to its default value.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### AbstractPreference

          public AbstractPreference(java.lang.String name,
                                    org.eclipse.jface.preference.IPreferenceStore store)

      Creates a new preference with the given name and the given store.
      Parameters:
        `name` - the preference name (not `null`)
        `store` - the preference store (not `null`)

  - ### Method Detail

    - #### getName

          public final java.lang.String getName()

      Returns the name of this preference.
      Returns:
        the preference name (never `null`)

    - #### getStore

          public final org.eclipse.jface.preference.IPreferenceStore getStore()

      Returns the store for this preference.
      Returns:
        the preference store (never `null`)

    - #### setToDefault

          public final void setToDefault()

      Sets the current value of this preference back to its default value.

      Note that the preferred way of re-initializing a preference to the appropriate default value is to call `setToDefault`. This is implemented by removing the preference value from the store, thereby exposing the default value.

    - #### isDefault

          public final boolean isDefault()

      Returns whether the current value of this preference has the default value.
      Returns:
        `true` if the preference has a known default value and its current value is the same, and `false` otherwise

    - #### addListener

          public final void addListener(IPreferenceListener listener)

      Description copied from interface: `IPreference`
      Adds the given listener for value change events to this preference. Has no effect if the listener is already registered.

      Make sure to remove the listener on the same preference instance.

      Specified by:
        `addListener` in interface `IPreference`
      Parameters:
        `listener` - not `null`

    - #### removeListener

          public final void removeListener(IPreferenceListener listener)

      Description copied from interface: `IPreference`
      Removes the given value change listener from this preference. Has no effect if the listener was not already registered.
      Specified by:
        `removeListener` in interface `IPreference`
      Parameters:
        `listener` - not `null`

Copyright (c) 2014, 2020 1C-Soft LLC and others. Made available under the Eclipse Public License 2.0