Package br.dev.rplus.cup.config
Class ConfigLoader
java.lang.Object
br.dev.rplus.cup.config.ConfigLoader
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Config
from
(InputStream input, String filename) Loads configuration data from anInputStream
, inferring the format from the file name.static Config
Loads a configuration file from a string path.static Config
Loads a configuration file from aPath
.
-
Constructor Details
-
ConfigLoader
public ConfigLoader()
-
-
Method Details
-
from
Loads a configuration file from aPath
.- Parameters:
path
- the path to the configuration file.- Returns:
- a populated
Config
instance. - Throws:
RuntimeException
- if an I/O error occurs.
-
from
Loads a configuration file from a string path.- Parameters:
path
- the path to the configuration file.- Returns:
- a populated
Config
instance.
-
from
Loads configuration data from anInputStream
, inferring the format from the file name.- Parameters:
input
- the open input streamfilename
- the file name (used only to detect the extension)- Returns:
- a populated
Config
instance - Throws:
IllegalArgumentException
- if the file type is unsupported
-