Package fr.sandro642.github.misc
Class YamlUtils
java.lang.Object
fr.sandro642.github.misc.YamlUtils
YamlUtils is a utility class for handling YAML files in the ConnectLib library.
It provides methods to read configuration values such as the base URL, logging settings, and routes from a YAML file.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
generateTemplateIfNotExists
(Map<Enum<?>, String> routes) Generates a template `infos.yml` file if it does not already exist.Retrieves the routes defined in the YAML configuration file.getURL()
Gets the base URL from the YAML configuration file.Checks if logging is enabled in the YAML configuration file.
-
Constructor Details
-
YamlUtils
public YamlUtils()
-
-
Method Details
-
getURL
Gets the base URL from the YAML configuration file. * This method reads the `infos.yml` file located in the directory specified by the- Returns:
- the base URL as a String, or null if an error occurs.
-
isLogEnabled
Checks if logging is enabled in the YAML configuration file. This method reads the `infos.yml` file and retrieves the `enableLogs` setting.- Returns:
- true if logging is enabled, false if disabled, or null if an error occurs.
-
getRoutes
Retrieves the routes defined in the YAML configuration file. This method reads the `infos.yml` file and returns a map of routes.- Returns:
- a map of route names to their corresponding paths, or null if an error occurs.
-
generateTemplateIfNotExists
Generates a template `infos.yml` file if it does not already exist. If the file exists, it updates the routes section with the provided routes.- Parameters:
routes
- a map of route names to their corresponding paths
-