Class SettingsStore

java.lang.Object
io.github.jbastgen.stemma.app.config.SettingsStore

public final class SettingsStore extends Object
Persists the settings as one small properties file in the portable configuration directory (see AppDirs). Reading never fails (missing or broken files give defaults); writing is atomic so a crash cannot leave a half-written file, and keeps the keys other parts of the application wrote.
  • Constructor Details

    • SettingsStore

      public SettingsStore(Path file)
      Parameters:
      file - settings.properties in the configuration folder
  • Method Details

    • defaultFile

      public static Path defaultFile()
      settings.properties in the portable configuration directory.
    • file

      public Path file()
      The settings file.
    • loadApp

      public AppSettings loadApp()
      Reads every global setting; whatever is missing or unreadable keeps its default.
    • saveApp

      public void saveApp(AppSettings a) throws IOException
      Writes the global settings; keys of other parts of the file stay as they are.
      Throws:
      IOException
    • load

      public BackendSettings load()
      The backend settings stored in the file; invalid values fall back to the defaults.
    • save

      public void save(BackendSettings settings) throws IOException
      Stores the backend settings; everything else in the file stays as it is.
      Throws:
      IOException
    • loadView

      public void loadView(ViewSettings view)
      Takes the stored look and layout over into view; whatever is not stored keeps its default.
    • saveViewIfChanged

      public boolean saveViewIfChanged(ViewSettings view) throws IOException
      Writes the look and layout if it differs from what is stored. Returns whether it wrote.
      Throws:
      IOException