Class Config
java.lang.Object
br.net.dd.netherwingcore.common.configuration.Config
This class represents a singleton Config responsible for managing the application's
Configuration.
The Config class ensures that the application's configuration is loaded and accessible globally
during runtime. It follows the Singleton design pattern to ensure a single instance of the config exists
throughout the application lifecycle.
Usage guide:
- Prior to calling
get(), initialize the config usingloadConfig(ConfigurationSample). - Attempting to access the configuration before initialization will result in an
IllegalStateException.
-
Method Summary
Modifier and TypeMethodDescriptionstatic Configurationget()Retrieves the cachedConfiguration.static IntegerRetrieves the cachedConfiguration.static StringRetrieves the cachedConfiguration.static voidloadConfig(ConfigurationSample sample) Loads the application's configuration into the config using the specifiedConfigurationSample.
-
Method Details
-
loadConfig
Loads the application's configuration into the config using the specifiedConfigurationSample. If the config instance does not already exist, it will be created and initialized during this method call.- Parameters:
sample- The configuration sample used to initialize the configuration.
-
get
Retrieves the cachedConfiguration.Ensure that
loadConfig(ConfigurationSample)is invoked before calling this method, otherwise anIllegalStateExceptionwill be thrown.- Returns:
- The application's
Configurationobject. - Throws:
IllegalStateException- If the config has not been initialized vialoadConfig(ConfigurationSample).
-
get
Retrieves the cachedConfiguration.Ensure that
loadConfig(ConfigurationSample)is invoked before calling this method, otherwise anIllegalStateExceptionwill be thrown.- Returns:
- The application's
Configurationobject. - Throws:
IllegalStateException- If the config has not been initialized vialoadConfig(ConfigurationSample).
-
get
Retrieves the cachedConfiguration.Ensure that
loadConfig(ConfigurationSample)is invoked before calling this method, otherwise anIllegalStateExceptionwill be thrown.- Returns:
- The application's
Configurationobject. - Throws:
IllegalStateException- If the config has not been initialized vialoadConfig(ConfigurationSample).
-