Interface Config<T>

Type Parameters:
T - the plain configuration POJO type

public interface Config<T>
Lifecycle handle for a plain @Configuration POJO loaded via ConfigurationLoader.from(path).loadPlain(...).

Because the POJO does not extend anything, persistence operations live on this handle instead of on the configuration object itself:


 Config<AppConfig> config = ConfigurationLoader.from(path).loadPlain(AppConfig::new);

 AppConfig app = config.get();
 app.setPort(9090);
 config.save();
 config.reload();
 
  • Method Summary

    Modifier and Type
    Method
    Description
    get()
    Returns the configuration POJO.
    Returns the per-key issues from the last load or reload (TOML and Properties formats).
    boolean
    Returns whether the configuration file is being watched for changes.
    void
    Reloads the POJO's fields from the configuration file and re-runs @PostInject methods.
    void
    Saves the current state of the POJO to the configuration file.
    void
    Registers a listener invoked after an automatic reload (requires auto-reload to be enabled via the loader builder).
    void
    Stops watching the configuration file.
  • Method Details

    • get

      T get()
      Returns the configuration POJO. The same instance is returned for the lifetime of this handle; reload() updates its fields in place.
    • save

      void save()
      Saves the current state of the POJO to the configuration file.
    • reload

      void reload()
      Reloads the POJO's fields from the configuration file and re-runs @PostInject methods.
    • getLastLoadIssues

      List<LoadIssue> getLastLoadIssues()
      Returns the per-key issues from the last load or reload (TOML and Properties formats). See ConfigurablePojo.getLastLoadIssues() for details on the semantics.
    • setOnAutoReload

      void setOnAutoReload(Runnable listener)
      Registers a listener invoked after an automatic reload (requires auto-reload to be enabled via the loader builder). Runs on the watcher thread — keep it short and thread-safe. Pass null to remove.
    • isAutoReloadActive

      boolean isAutoReloadActive()
      Returns whether the configuration file is being watched for changes.
    • stopAutoReload

      void stopAutoReload()
      Stops watching the configuration file. save() and reload() continue to work.