Package pi.config

Class ConfigurationLoader

java.lang.Object
pi.config.ConfigurationLoader
Direct Known Subclasses:
MainConfiguration

public class ConfigurationLoader extends Object
Configuration class that manages multiple configuration groups and handles loading and saving settings.
Since:
0.42.0
Author:
Steffen Wilke, Matthias Wilke
  • Constructor Details

    • ConfigurationLoader

      public ConfigurationLoader(ConfigurationGroup... configurationGroups)
      Initializes a new instance of the Configuration class.
      Parameters:
      configurationGroups - The configuration groups managed by this instance.
    • ConfigurationLoader

      public ConfigurationLoader(String path, ConfigurationGroup... configurationGroups)
      Constructs a new instance of the Configuration class using the specified file name. This constructor converts the provided file name string into a Path object and delegates the initialization to another constructor.
      Parameters:
      path - The path of the file from which to load the settings.
      configurationGroups - The configuration groups managed by this instance.
    • ConfigurationLoader

      public ConfigurationLoader(Path path, ConfigurationGroup... configurationGroups)
      Initializes a new instance of the Configuration class.
      Parameters:
      path - The path of the file from which to load the settings.
      configurationGroups - The configuration groups managed by this instance.
  • Method Details

    • getConfigurationGroup

      public <T extends ConfigurationGroup> T getConfigurationGroup(Class<T> groupClass)
      Gets the strongly typed configuration group if it was previously added to the configuration.
      Type Parameters:
      T - The type of the config group.
      Parameters:
      groupClass - The class that provides the generic type for this method.
      Returns:
      The configuration group of the specified type or null if none can be found.
    • getConfigurationGroup

      public ConfigurationGroup getConfigurationGroup(String prefix)
      Gets the configuration group with the specified prefix.
      Parameters:
      prefix - The prefix of the configuration group to retrieve.
      Returns:
      The configuration group with the specified prefix, or null if none can be found.
    • getConfigurationGroups

      public List<ConfigurationGroup> getConfigurationGroups()
      Gets all ConfigurationGroups from the configuration.
      Returns:
      All config groups.
    • add

      public void add(ConfigurationGroup... groups)
      Adds the specified configuration group to the configuration.
      Parameters:
      groups - The group to add.
    • getPath

      public Path getPath()
      Gets the path of the file to which this configuration is saved.
      Returns:
      The path of the configuration file.
      See Also:
    • load

      public void load()
      Versucht, die Konfiguration aus der Datei im Anwendungsordner zu laden.

      Wenn keine vorhanden ist, versucht es, die Datei aus einem beliebigen Ressourcenordner zu laden. Wenn keine vorhanden ist, erstellt es eine neue Konfigurationsdatei im Anwendungsordner.

    • save

      public void save()
      Saves this configuration to a file with the specified name of this instance (config.properties is the engines default config file).
      See Also: