Interface ModuleConfig

All Known Implementing Classes:
CLIModuleConfig, GLFWRenderModuleConfig, RenderModuleConfig, SimulatorModuleConfig, VulkanGLFWRenderModuleConfig, VulkanModuleConfig, VulkanRenderModuleConfig, WebserverModuleConfig

public interface ModuleConfig
A module's persisted settings, backed by a java.util.Properties file under config/.

A configuration is never allowed to fail because its file is absent or incomplete. Loading substitutes a documented default for every key it cannot read, records that it did so, and the owning module then writes the completed file back:

this.config = new XModuleConfig(this.logger).load();
if (this.config.isDirty()) this.config.save();

Implementations must satisfy requirements R31 through R37 of the Module System Specification.

  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Returns whether this configuration differs from what is on disk.
    Reads this configuration from disk, substituting defaults for anything missing or invalid.
    void
    Writes this configuration to disk, creating config/ if it does not exist.
  • Method Details

    • load

      ModuleConfig load() throws IOException
      Reads this configuration from disk, substituting defaults for anything missing or invalid.

      An absent file is not an error. For each key that is missing or fails to parse, an implementation logs a warning identifying the key and the accepted range, substitutes the documented default, and sets the dirty flag.

      Returns:
      this configuration, so that construction and loading compose
      Throws:
      IOException - if the file exists but cannot be read
    • save

      void save() throws IOException
      Writes this configuration to disk, creating config/ if it does not exist.

      Every known key is written, not only those that changed, so that a user who deletes the file gets a complete one back on the next run. The dirty flag is cleared on success.

      Throws:
      IOException - if the directory cannot be created or the file cannot be written
    • isDirty

      boolean isDirty()
      Returns whether this configuration differs from what is on disk.

      Set whenever the in-memory state diverges from the file. load() substituting a default for a missing or unparseable key is the usual cause, but any later change to a value counts equally. save() clears it, since writing the file makes the two agree again.

      Returns:
      true if the file does not match this configuration and should be rewritten