Class MemoryMessageHistory
java.lang.Object
com.developer.nefarious.zjoule.plugin.chat.memory.MemoryMessageHistory
- All Implemented Interfaces:
IMemoryMessageHistory
Manages the storage and retrieval of chat message history in Eclipse preferences.
This class provides functionality to persist, retrieve, and manage
MessageHistory
objects using an object serializer and Eclipse's preferences API.
Implements the IMemoryMessageHistory
interface.-
Field Summary
Fields inherited from interface com.developer.nefarious.zjoule.plugin.chat.memory.IMemoryMessageHistory
KEY
-
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Clears the stored chat message history from memory.static MemoryMessageHistory
Retrieves the singleton instance ofMemoryMessageHistory
.static void
initialize
(IObjectSerializer objectSerializer, IEclipseMemory eclipseMemory) Initializes the singleton instance ofMemoryMessageHistory
.isEmpty()
Checks if the stored chat message history is empty.load()
Loads the chat message history from memory.static void
Resets the singleton instance ofMemoryMessageHistory
.void
save
(MessageHistory messageHistory) Saves the givenMessageHistory
object to memory.
-
Method Details
-
getInstance
Retrieves the singleton instance ofMemoryMessageHistory
.- Returns:
- the singleton instance of
MemoryMessageHistory
. - Throws:
IllegalStateException
- if the instance is not initialized.
-
initialize
Initializes the singleton instance ofMemoryMessageHistory
.- Parameters:
objectSerializer
- the serializer for handling object serialization and deserialization.eclipseMemory
- the handler for managing Eclipse preferences storage.
-
resetInstance
public static void resetInstance()Resets the singleton instance ofMemoryMessageHistory
. This is useful for testing or reinitializing the instance. -
clear
public void clear()Clears the stored chat message history from memory. Deletes the data associated with the keyKEY
in the persistence mechanism.- Specified by:
clear
in interfaceIMemoryMessageHistory
-
isEmpty
Checks if the stored chat message history is empty.- Specified by:
isEmpty
in interfaceIMemoryMessageHistory
- Returns:
true
if the stored message history is empty or null;false
otherwise.
-
load
Loads the chat message history from memory.- Specified by:
load
in interfaceIMemoryMessageHistory
- Returns:
- the
MessageHistory
object, ornull
if deserialization fails or no data is found.
-
save
Saves the givenMessageHistory
object to memory.- Specified by:
save
in interfaceIMemoryMessageHistory
- Parameters:
messageHistory
- theMessageHistory
object to save.
-