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:
parent
78b6039d39
commit
20b7a353b8
|
@ -25,6 +25,7 @@ import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
// TODO: Allow registering load-Listeners
|
// TODO: Allow registering load-Listeners
|
||||||
|
// TODO: Provide method to only save if changed
|
||||||
public class SongodaYamlConfig extends YamlConfiguration {
|
public class SongodaYamlConfig extends YamlConfiguration {
|
||||||
protected final String cannotCreateBackupCopyExceptionPrefix = "Unable to create backup copy of config file: ";
|
protected final String cannotCreateBackupCopyExceptionPrefix = "Unable to create backup copy of config file: ";
|
||||||
|
|
||||||
|
@ -81,6 +82,10 @@ public class SongodaYamlConfig extends YamlConfiguration {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ConfigEntry getAsEntry(String key) {
|
||||||
|
return new ConfigEntry(this, key);
|
||||||
|
}
|
||||||
|
|
||||||
protected void registerConfigEntry(ConfigEntry entry) {
|
protected void registerConfigEntry(ConfigEntry entry) {
|
||||||
this.configEntries.put(entry.key, entry);
|
this.configEntries.put(entry.key, entry);
|
||||||
}
|
}
|
||||||
|
@ -138,7 +143,7 @@ public class SongodaYamlConfig extends YamlConfiguration {
|
||||||
public void load(Reader reader) {
|
public void load(Reader reader) {
|
||||||
super.load(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 {
|
try {
|
||||||
upgradeOldConfigVersion();
|
upgradeOldConfigVersion();
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
|
|
Loading…
Reference in New Issue