Class TemporaryMemoryOllamaEndpoint

java.lang.Object
com.developer.nefarious.zjoule.plugin.login.memory.TemporaryMemoryOllamaEndpoint
All Implemented Interfaces:
ITemporaryMemoryObject, IMemoryObject<String>

public class TemporaryMemoryOllamaEndpoint extends Object implements IMemoryObject<String>, ITemporaryMemoryObject
A temporary memory storage for the Ollama endpoint used during the login process.

The TemporaryMemoryOllamaEndpoint stores the Ollama endpoint in Eclipse preferences temporarily before persisting it permanently. It provides methods to load, save, clear, and persist data. This class follows a singleton pattern and requires explicit initialization.

  • Field Details

    • KEY

      public static final String KEY
      The preference key used for temporarily storing the Ollama endpoint.
      See Also:
  • Method Details

    • getInstance

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

      public static void initialize(IEclipseMemory eclipseMemory)
      Initializes the singleton instance of TemporaryMemoryOllamaEndpoint.

      This method must be called before accessing getInstance().

      Parameters:
      eclipseMemory - the IEclipseMemory instance to be used for preference storage.
    • resetInstance

      public static void resetInstance()
      Resets the singleton instance.

      This method clears the instance reference, allowing re-initialization.

    • isEmpty

      public Boolean isEmpty()
      Checks if the stored data is empty or invalid.
      Specified by:
      isEmpty in interface IMemoryObject<String>
      Returns:
      true if the stored data is empty or invalid; false otherwise.
    • load

      public String load()
      Loads the data from memory.
      Specified by:
      load in interface IMemoryObject<String>
      Returns:
      the stored object of type T, or null if no data is found or loading fails.
    • persist

      public void persist()
      Persists the temporary memory object to permanent storage.
      Specified by:
      persist in interface ITemporaryMemoryObject
    • save

      public void save(String ollamaEndpoint)
      Saves the given data to memory.
      Specified by:
      save in interface IMemoryObject<String>
      Parameters:
      ollamaEndpoint - the object of type T to save.
    • clear

      public void clear()
      Specified by:
      clear in interface IMemoryObject<String>