Module de.seggebaeing.sqlanalyzer
Class ConfigService
java.lang.Object
de.seggebaeing.sqlanalyzer.logic.service.ConfigService
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 Summary
Modifier and TypeMethodDescriptionReturns the value associated with the given configuration key.static ConfigService
int
Returns the integer value of a configuration key, or a fallback if missing or invalid.Returns the base directory for persisted data files, resolved as<configDir>/saves
.void
save()
Persists the current properties to disk atCONFIG_PATH
.void
Sets the value for the given configuration key in memory.
-
Method Details
-
getInstance
-
save
public void save()Persists the current properties to disk atCONFIG_PATH
.Creates or overwrites the configuration file and writes a
"Config"
comment header. Wraps anyIOException
in aRuntimeException
. -
get
Returns the value associated with the given configuration key.- Parameters:
key
- the property key- Returns:
- the property value, or
null
if not set
-
set
Sets the value for the given configuration key in memory.Call
save()
to persist changes to disk.- Parameters:
key
- the property keyvalue
- the property value
-
getInt
Returns the integer value of a configuration key, or a fallback if missing or invalid.- Parameters:
key
- the property keyfallback
- value to return if the property is absent or not a valid integer- Returns:
- the parsed integer value, or
fallback
on error
-
getSavesBasePath
Returns the base directory for persisted data files, resolved as<configDir>/saves
.- Returns:
- path to the saves directory
-