Class ConfigLoader

java.lang.Object
br.dev.rplus.cup.config.ConfigLoader

public final class ConfigLoader extends Object
Utility class that detects the file type (YAML or .properties), loads the data through the proper ConfigSource, and returns a ready-to-use Config instance.
  • Constructor Details

    • ConfigLoader

      public ConfigLoader()
  • Method Details

    • from

      public static Config from(Path path)
      Loads a configuration file from a Path.
      Parameters:
      path - the path to the configuration file.
      Returns:
      a populated Config instance.
      Throws:
      RuntimeException - if an I/O error occurs.
    • from

      public static Config from(String path)
      Loads a configuration file from a string path.
      Parameters:
      path - the path to the configuration file.
      Returns:
      a populated Config instance.
    • from

      public static Config from(InputStream input, String filename)
      Loads configuration data from an InputStream, inferring the format from the file name.
      Parameters:
      input - the open input stream
      filename - the file name (used only to detect the extension)
      Returns:
      a populated Config instance
      Throws:
      IllegalArgumentException - if the file type is unsupported