java.lang.Object
de.seggebaeing.sqlanalyzer.logic.service.ConfigService

public class ConfigService extends Object
Application configuration service (singleton) backed by a platform-specific properties file.

Resolves a config path under: Windows %APPDATA%/sql-analyzer, macOS ~/Library/Application Support/sql-analyzer, Linux/Unix $XDG_CONFIG_HOME or ~/.config/sql-analyzer, then loads/saves config.properties. Provides typed accessors and defaults, and exposes a base path for persistent saves. Access via getInstance().

Since:
1.0
Author:
Felix Seggebäing
  • Method Details

    • getInstance

      public static ConfigService getInstance()
    • save

      public void save()
      Persists the current properties to disk at CONFIG_PATH.

      Creates or overwrites the configuration file and writes a "Config" comment header. Wraps any IOException in a RuntimeException.

    • get

      public String get(String key)
      Returns the value associated with the given configuration key.
      Parameters:
      key - the property key
      Returns:
      the property value, or null if not set
    • set

      public void set(String key, String value)
      Sets the value for the given configuration key in memory.

      Call save() to persist changes to disk.

      Parameters:
      key - the property key
      value - the property value
    • getInt

      public int getInt(String key, int fallback)
      Returns the integer value of a configuration key, or a fallback if missing or invalid.
      Parameters:
      key - the property key
      fallback - value to return if the property is absent or not a valid integer
      Returns:
      the parsed integer value, or fallback on error
    • getSavesBasePath

      public Path getSavesBasePath()
      Returns the base directory for persisted data files, resolved as <configDir>/saves.
      Returns:
      path to the saves directory