Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions src/main/java/com/houarizegai/calculator/theme/ThemeLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,17 @@ private ThemeLoader() {
throw new AssertionError("Constructor is not allowed");
}

/**
* Loads themes from the application.yaml file and returns them as a map.
*
* @return A map containing the loaded themes.
* @throws IOException if an I/O error occurs while reading the application.yaml file.
*
* Example:
* <pre>{@code
* Map<String, Theme> themes = loadThemes();
* }</pre>
*/
public static Map<String, Theme> loadThemes() {

ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
Expand All @@ -28,6 +39,18 @@ public static Map<String, Theme> loadThemes() {
}
}

/**
* Loads themes from the specified YAML file and returns a map of theme names to Theme objects.
*
* @param theme the name of the theme to load
* @return a map of theme names to Theme objects
* @throws IOException if an error occurs while reading the YAML file
*
* Example:
* <pre>{@code
* Map<String, Theme> themes = loadThemes("default");
* }</pre>
*/
public static Map<String, Theme> loadThemes(String theme) {
ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
mapper.findAndRegisterModules();
Expand All @@ -39,6 +62,18 @@ public static Map<String, Theme> loadThemes(String theme) {
}
}

/**
* Loads themes from the specified YAML file and returns a map of theme names to Theme objects.
*
* @param theme the theme to load
* @param dType the type of the theme
* @return a map of theme names to Theme objects
* @throws IOException if an I/O error occurs while reading the YAML file
*
* Example:
*
* Map<String, Theme> themes = loadThemes("default", "dark");
*/
public static Map<String, Theme> loadThemes(String theme, String dType) {
ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
mapper.findAndRegisterModules();
Expand Down