Class ConfigurationHelper
java.lang.Object
eu.svjatoslav.alyverkko_cli.configuration.ConfigurationHelper
Helper class for configuration file operations. Provides methods for loading configurations and determining the default configuration file path in the user's home directory.
Key functionality includes:
- Configuration file path resolution
- YAML deserialization
- Error handling for missing configurations
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe default path for the YAML config file, typically under the user's home directory. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic FilegetConfigurationFile(eu.svjatoslav.commons.cli_helper.parameter_parser.parameter.FileOption configFileOption) Returns the configuration file from the given option, or the default path if not present.static ConfigurationloadConfiguration(File configFile) Loads the configuration from a given file, or from the default path ifconfigFileis null.
-
Field Details
-
DEFAULT_CONFIG_FILE_PATH
The default path for the YAML config file, typically under the user's home directory.
-
-
Constructor Details
-
ConfigurationHelper
public ConfigurationHelper()
-
-
Method Details
-
loadConfiguration
Loads the configuration from a given file, or from the default path ifconfigFileis null.- Parameters:
configFile- the file containing the YAML config; may be null.- Returns:
- the
Configurationobject, or null if not found/invalid. - Throws:
IOException- if file I/O fails during reading.
-
getConfigurationFile
public static File getConfigurationFile(eu.svjatoslav.commons.cli_helper.parameter_parser.parameter.FileOption configFileOption) Returns the configuration file from the given option, or the default path if not present.- Parameters:
configFileOption- the CLI option for the config file.- Returns:
- the configuration file to load.
-