Top Description Fields Constructors Methods
com.dlsc.gemsfx.util

public Class PreferencesHistoryManager<T>

extends HistoryManager<T>
Class Inheritance
Known Direct Subclasses
com.dlsc.gemsfx.util.StringHistoryManager
Type Parameters
<T>
the type of objects managed in the history
Imports
javafx.util.StringConverter, org.apache.commons.lang3.StringUtils, java.util.Arrays, .Objects, java.util.logging.Logger, java.util.prefs.Preferences, java.util.stream.Collectors

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
HistoryManager, StringConverter

Field Summary

Modifier and TypeField and Description
private final StringConverter<T>
public static String
DELIMITER

Using Unicode Record Separator as delimiter.

private final String
private static final Logger
private final Preferences

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected void
loadHistory()

Implements abstract com.dlsc.gemsfx.util.HistoryManager.loadHistory.

Loads the history items from the preferences.

protected void
storeHistory()

Implements abstract com.dlsc.gemsfx.util.HistoryManager.storeHistory.

Stores the history items in the preferences.

Inherited from com.dlsc.gemsfx.util.HistoryManager:
addaddclearfilterPropertygetAllUnmodifiablegetFiltergetMaxHistorySizemaxHistorySizePropertyremoveremovesetsetFiltersetMaxHistorySize

Field Detail

converterback to summary
private final StringConverter<T> converter
DELIMITERback to summary
public static String DELIMITER

Using Unicode Record Separator as delimiter. This character is not likely to be used in the history items.

keyback to summary
private final String key
LOGback to summary
private static final Logger LOG

Hides com.dlsc.gemsfx.util.HistoryManager.LOG.

preferencesback to summary
private final Preferences preferences

Constructor Detail

PreferencesHistoryManagerback to summary
public PreferencesHistoryManager(Preferences preferences, String key, StringConverter<T> converter)

Method Detail

loadHistoryback to summary
protected void loadHistory()

Implements abstract com.dlsc.gemsfx.util.HistoryManager.loadHistory.

Loads the history items from the preferences.

Annotations
@Override
storeHistoryback to summary
protected void storeHistory()

Implements abstract com.dlsc.gemsfx.util.HistoryManager.storeHistory.

Stores the history items in the preferences.

Annotations
@Override