Class MemoryMessageHistory

java.lang.Object
com.developer.nefarious.zjoule.plugin.chat.memory.MemoryMessageHistory
All Implemented Interfaces:
IMemoryMessageHistory

public class MemoryMessageHistory extends Object implements 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.
  • Method Details

    • getInstance

      public static MemoryMessageHistory getInstance()
      Retrieves the singleton instance of MemoryMessageHistory.
      Returns:
      the singleton instance of MemoryMessageHistory.
      Throws:
      IllegalStateException - if the instance is not initialized.
    • initialize

      public static void initialize(IObjectSerializer objectSerializer, IEclipseMemory eclipseMemory)
      Initializes the singleton instance of MemoryMessageHistory.
      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 of MemoryMessageHistory. 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 key KEY in the persistence mechanism.
      Specified by:
      clear in interface IMemoryMessageHistory
    • isEmpty

      public Boolean isEmpty()
      Checks if the stored chat message history is empty.
      Specified by:
      isEmpty in interface IMemoryMessageHistory
      Returns:
      true if the stored message history is empty or null; false otherwise.
    • load

      public MessageHistory load()
      Loads the chat message history from memory.
      Specified by:
      load in interface IMemoryMessageHistory
      Returns:
      the MessageHistory object, or null if deserialization fails or no data is found.
    • save

      public void save(MessageHistory messageHistory)
      Saves the given MessageHistory object to memory.
      Specified by:
      save in interface IMemoryMessageHistory
      Parameters:
      messageHistory - the MessageHistory object to save.