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

public class PreferencesHistoryManager<T> extends HistoryManager<T>
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:
  • Field Details

    • DELIMITER

      public static String 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:
      storeHistory in class HistoryManager<T>
    • loadHistory

      protected void loadHistory()
      Loads the history items from the preferences.
      Specified by:
      loadHistory in class HistoryManager<T>