Interface ModuleConfig
- All Known Implementing Classes:
CLIModuleConfig, GLFWRenderModuleConfig, RenderModuleConfig, SimulatorModuleConfig, VulkanGLFWRenderModuleConfig, VulkanModuleConfig, VulkanRenderModuleConfig, WebserverModuleConfig
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 TypeMethodDescriptionbooleanisDirty()Returns whether this configuration differs from what is on disk.load()Reads this configuration from disk, substituting defaults for anything missing or invalid.voidsave()Writes this configuration to disk, creatingconfig/if it does not exist.
-
Method Details
-
load
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
Writes this configuration to disk, creatingconfig/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:
trueif the file does not match this configuration and should be rewritten
-