From 20b7a353b8336f9ff29f66954dfe8c73f651dbdc Mon Sep 17 00:00:00 2001 From: Christian Koop Date: Thu, 18 Aug 2022 23:08:58 +0200 Subject: [PATCH] Adds SongodaYamlConfig#getAsEntry(String) for convenience If you are reading a config dynamically instead of fully creating it with all the entries beforehand, this method can be used to easily access the *converted/casted* values. --- .../core/configuration/songoda/SongodaYamlConfig.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Core/src/main/java/com/songoda/core/configuration/songoda/SongodaYamlConfig.java b/Core/src/main/java/com/songoda/core/configuration/songoda/SongodaYamlConfig.java index aa63ea2e..96cfe758 100644 --- a/Core/src/main/java/com/songoda/core/configuration/songoda/SongodaYamlConfig.java +++ b/Core/src/main/java/com/songoda/core/configuration/songoda/SongodaYamlConfig.java @@ -25,6 +25,7 @@ import java.util.logging.Level; import java.util.logging.Logger; // TODO: Allow registering load-Listeners +// TODO: Provide method to only save if changed public class SongodaYamlConfig extends YamlConfiguration { protected final String cannotCreateBackupCopyExceptionPrefix = "Unable to create backup copy of config file: "; @@ -81,6 +82,10 @@ public class SongodaYamlConfig extends YamlConfiguration { return false; } + public ConfigEntry getAsEntry(String key) { + return new ConfigEntry(this, key); + } + protected void registerConfigEntry(ConfigEntry entry) { this.configEntries.put(entry.key, entry); } @@ -138,7 +143,7 @@ public class SongodaYamlConfig extends YamlConfiguration { public void load(Reader reader) { super.load(reader); - // The interface does not allow to throw an exception, so we log it instead. + // FIXME: The interface does not allow to throw an exception, so we log it instead. try { upgradeOldConfigVersion(); } catch (IOException ex) {