public class PreferenceMemento extends Object
A utility to change and remember preference values and later restore there original value. The first time a preference value is changed its current value is stored. Later you can reset all preference values (which are changed through this class) to the state they had when creating the memento.
This class is most useful for testing to prevent leakage of preference changes between individual tests.
setValueSet the value for the given preference on the given store.
The first time this preference is changed its value before change is remembered and can later be restored using
- Type Parameters:
T- the preference value type. The type must have a corresponding
store- the preference store to manipulate (not
name- the name of the preference (not
value- the new current value of the preference.
IllegalArgumentException- when setting a type which is not supported by
- See Also:
resetPreferencespublic void resetPreferences()Reset every preference changed by this utility to its state before the first change. After this the instance can still be used as if it was just created.