Class AukioConfig

java.lang.Object
eu.svjatoslav.aukio.cfg.AukioConfig

public final class AukioConfig extends Object
Shared user configuration for the whole Aukio family (engine, workspace app, environments), stored as a single YAML file.

Default file: ~/.config/aukio/config.yaml (override with -Daukio.config=<path>; the legacy -De3d.config=<path> is honored as a fallback for engine-only tooling). A missing file means empty configuration — every getter falls back to its caller supplied default.

Tenancy is by YAML section, flat camelCase keys per section: e3d (engine), fo4 (Fallout 4 environment), app (workspace app; its state subtree is written by the app at runtime). Unknown keys in the file are preserved verbatim.

Freshness: every getter checks the file's (mtime, size, fileKey) stamp and re-parses only when it changed, so hand edits made while an app is running become visible on the next read. Writes (setString and friends) lock a sidecar <file>.lock, re-read the file under the lock, merge the new key, and atomically rename a temp file into place — a hand edit made between the writer's read and write survives. All cooperating processes must use this class; an editor saving a stale buffer over newer YAML is the one race no file format can solve (Emacs's changed-on-disk warning is the guard).

Known limitation: SnakeYAML rewrites the file on the first set, so human-written header comments are not preserved through app writes — conventions live in each repo's AGENTS.org, not in the file.

Instances are cached per resolved path in a per-JVM registry: get() returns the same instance to every caller in this JVM (engine, workspace app, environments), so the stamp cache is shared. Separate JVMs each hold their own instance.

  • Method Details

    • get

      public static AukioConfig get()
      Instance for the default file, honoring system property overrides.
    • forFile

      public static AukioConfig forFile(String path)
      Cached instance for the given file (same path → same instance).
    • forFile

      public static AukioConfig forFile(Path path)
      Cached instance for the given file (same path → same instance).
    • path

      public Path path()
      The file this instance reads and writes.
    • getString

      public String getString(String dottedPath, String fallback)
      String value at the dotted path, or fallback when absent.
    • getDouble

      public double getDouble(String dottedPath, double fallback)
      Numeric value at the dotted path, or fallback when absent/unparseable.
    • getInt

      public int getInt(String dottedPath, int fallback)
      Numeric value at the dotted path truncated to int.
    • getBoolean

      public boolean getBoolean(String dottedPath, boolean fallback)
      Boolean value at the dotted path, or fallback when absent.
    • getStringMap

      public Map<String,String> getStringMap(String dottedPath)
      All scalar leaves under a section, flattened to dotted keys (e.g. the fo4 section's path and spawnAt entries). Non-scalar values nested deeper are flattened too; absent section yields an empty map.
    • setString

      public void setString(String dottedPath, String value)
      Sets a string value, creating intermediate sections as needed.
    • setInt

      public void setInt(String dottedPath, int value)
      Sets an int value.
    • setDouble

      public void setDouble(String dottedPath, double value)
      Sets a double value.
    • setBoolean

      public void setBoolean(String dottedPath, boolean value)
      Sets a boolean value.