Interface IConfigHandler
- All Known Implementing Classes:
StandardConfigHandler
public interface IConfigHandler
Config component specification.
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classIConfigHandler.MessageUsed for sending out updates by implementations of IConfigHandler. -
Method Summary
Modifier and Type Method Description voidcreateConfig(String name)Sets up a new configuration in program and in memory.Objectget(String key)Returns the configuration value for the given key.Objectget(String key, Object defaultValue)Returns the configuration value for the given key, or default value if key not set.default ObjectgetOrDefault(String key, Object defaultValue)Returns the configuration value for the given key, or default value if key not set.default booleanloadConfig()Loads the configuration file from the given URI.booleanloadConfig(String name)Loads the configuration file from the given URI.voidresetConfig()Loads the default config.voidsaveConfig()Saves the current configuration.voidset(String key, String val)Sets the configuration value for the given key.
-
Method Details
-
loadConfig
Loads the configuration file from the given URI. Returns true if successful, false otherwise.- Parameters:
name- Config name.- Returns:
- True if loaded, false otherwise.
-
loadConfig
default boolean loadConfig()Loads the configuration file from the given URI. Returns true if successful, false otherwise.- Returns:
- True if loaded, false otherwise.
-
saveConfig
void saveConfig()Saves the current configuration. -
resetConfig
void resetConfig()Loads the default config. -
createConfig
Sets up a new configuration in program and in memory.- Parameters:
name- New configuration name.
-
set
Sets the configuration value for the given key.- Parameters:
key- Config key.val- Value to set.
-
get
Returns the configuration value for the given key.- Parameters:
key- Config key.- Returns:
- Value if set, otherwise null.
-
get
Returns the configuration value for the given key, or default value if key not set.- Parameters:
key- Config key.defaultValue- Default value to return if config key not set.- Returns:
- Value if set, otherwise defaultValue.
-
getOrDefault
Returns the configuration value for the given key, or default value if key not set.- Parameters:
key- Config key.defaultValue- Default value to return if config key not set.- Returns:
- Value if set, otherwise defaultValue.
-