org.eclipse.ocl.common.internal.preferences
Class Preference<T>

java.lang.Object
  extended by org.eclipse.ocl.common.internal.preferences.Preference<T>
Type Parameters:
T - the type of the option's value
All Implemented Interfaces:
PreferenceableOption<T>, PreferenceableOption.PreferenceableOption2<T>
Direct Known Subclasses:
BooleanPreference, ClassPreference, EnumerationPreference, StringPreference

public abstract class Preference<T>
extends java.lang.Object
implements PreferenceableOption.PreferenceableOption2<T>

Abstract implementation of a configurable preference option. Derived classes support specific types.

See Also:
BooleanPreference, ClassPreference, EnumerationPreference

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.eclipse.ocl.common.preferences.PreferenceableOption
PreferenceableOption.Listener, PreferenceableOption.PreferenceableOption2<T>
 
Field Summary
 T defaultValue
           
 java.lang.String key
           
 java.lang.String pluginId
           
 
Constructor Summary
Preference(java.lang.String pluginId, java.lang.String key, T defaultValue)
           
 
Method Summary
 void addListener(PreferenceableOption.Listener listener)
          Add a listener to be notified of changes.
 void fireChanged(java.lang.String key, java.lang.Object oldValue, java.lang.Object newValue)
          Call-back notification that the Eclipse preference identified by a key, has changed from oldValue to new Value.
 T getDefaultValue()
          Obtains the option's default value.
 java.lang.String getKey()
          Obtains my string key, which may be used for persistence in a preference store.
 java.lang.String getPluginId()
          Returns the plugin qualifier for the key.
 T getPreferredValue()
          Get the preferred value of this option.
 void removeListener(PreferenceableOption.Listener listener)
          Remove a listener to be notified of changes.
 void setDefaultValue(T defaultValue)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.eclipse.ocl.common.preferences.PreferenceableOption
getValueOf
 

Field Detail

pluginId

public final java.lang.String pluginId

key

public final java.lang.String key

defaultValue

public T defaultValue
Constructor Detail

Preference

public Preference(@NonNull
                  java.lang.String pluginId,
                  @NonNull
                  java.lang.String key,
                  @Nullable
                  T defaultValue)
Method Detail

addListener

public void addListener(@NonNull
                        PreferenceableOption.Listener listener)
Description copied from interface: PreferenceableOption.PreferenceableOption2
Add a listener to be notified of changes.

Specified by:
addListener in interface PreferenceableOption.PreferenceableOption2<T>
Since:
1.1

fireChanged

public void fireChanged(java.lang.String key,
                        java.lang.Object oldValue,
                        java.lang.Object newValue)
Description copied from interface: PreferenceableOption.PreferenceableOption2
Call-back notification that the Eclipse preference identified by a key, has changed from oldValue to new Value.

Specified by:
fireChanged in interface PreferenceableOption.PreferenceableOption2<T>
Since:
1.1

getKey

@NonNull
public java.lang.String getKey()
Obtains my string key, which may be used for persistence in a preference store.

Specified by:
getKey in interface PreferenceableOption<T>
Returns:
my key. Is never null

getPluginId

@NonNull
public java.lang.String getPluginId()
Description copied from interface: PreferenceableOption
Returns the plugin qualifier for the key.

Specified by:
getPluginId in interface PreferenceableOption<T>

getDefaultValue

@Nullable
public T getDefaultValue()
Obtains the option's default value.

Specified by:
getDefaultValue in interface PreferenceableOption<T>
Returns:
my default value, which default-default is null

getPreferredValue

@Nullable
public T getPreferredValue()
Get the preferred value of this option. When running standalone this is the built-in default. When running in Eclipse, the built-in default may be overridden by a user preference.

Specified by:
getPreferredValue in interface PreferenceableOption.PreferenceableOption2<T>
Since:
1.1

removeListener

public void removeListener(@NonNull
                           PreferenceableOption.Listener listener)
Description copied from interface: PreferenceableOption.PreferenceableOption2
Remove a listener to be notified of changes.

Specified by:
removeListener in interface PreferenceableOption.PreferenceableOption2<T>
Since:
1.1

setDefaultValue

public void setDefaultValue(@Nullable
                            T defaultValue)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object