Interface IConfigHandler
- All Known Implementing Classes:
StandardConfigHandler
public interface IConfigHandler
Config component specification.
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
IConfigHandler.Message
Used for sending out updates by implementations of IConfigHandler. -
Method Summary
Modifier and Type Method Description void
createConfig(String name)
Sets up a new configuration in program and in memory.Object
get(String key)
Returns the configuration value for the given key.Object
get(String key, Object defaultValue)
Returns the configuration value for the given key, or default value if key not set.default Object
getOrDefault(String key, Object defaultValue)
Returns the configuration value for the given key, or default value if key not set.default boolean
loadConfig()
Loads the configuration file from the given URI.boolean
loadConfig(String name)
Loads the configuration file from the given URI.void
resetConfig()
Loads the default config.void
saveConfig()
Saves the current configuration.void
set(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.
-