Class PreferencesHistoryManager<T>
java.lang.Object
com.dlsc.gemsfx.util.HistoryManager<T>
com.dlsc.gemsfx.util.PreferencesHistoryManager<T>
- Type Parameters:
T- the type of objects managed in the history
- Direct Known Subclasses:
StringHistoryManager
Manages a history of items of type T, storing them in a Java Preferences backend.
This class supports generic types T, allowing for flexible usage with any object type that
can be converted to and from a string representation using a provided
StringConverter.
The history is maintained in a list that is limited by a specified maximum size. If the limit is exceeded, the oldest items are removed. The history management includes functionalities to add, remove, clear, and retrieve history items. Changes to the history are automatically persisted to the Preferences store using the specified delimiter and preferences key.
This class is particularly useful for applications needing to maintain a persistent, manageable history of user actions or data entries, where entries must be stored across sessions in a simple and effective manner.
Instances of this class are not thread-safe. If concurrent access is required, it should be managed externally.
- See Also:
-
Property Summary
Properties inherited from class HistoryManager
filter, maxHistorySize -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionPreferencesHistoryManager(Preferences preferences, String key, javafx.util.StringConverter<T> converter) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidLoads the history items from the preferences.protected voidStores the history items in the preferences.Methods inherited from class HistoryManager
add, add, clear, filterProperty, getAllUnmodifiable, getFilter, getMaxHistorySize, maxHistorySizeProperty, remove, remove, set, setFilter, setMaxHistorySize
-
Field Details
-
DELIMITER
Using Unicode Record Separator as delimiter. This character is not likely to be used in the history items.
-
-
Constructor Details
-
PreferencesHistoryManager
public PreferencesHistoryManager(Preferences preferences, String key, javafx.util.StringConverter<T> converter)
-
-
Method Details
-
storeHistory
protected void storeHistory()Stores the history items in the preferences.- Specified by:
storeHistoryin classHistoryManager<T>
-
loadHistory
protected void loadHistory()Loads the history items from the preferences.- Specified by:
loadHistoryin classHistoryManager<T>
-