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.
This commit is contained in:
Christian Koop 2022-08-18 23:08:58 +02:00
parent 78b6039d39
commit 20b7a353b8
No known key found for this signature in database
GPG Key ID: 89A8181384E010A3
1 changed files with 6 additions and 1 deletions

View File

@ -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) {