Package org.apache.gravitino
Class Config
java.lang.Object
org.apache.gravitino.Config
The Config class is responsible for managing configuration settings.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T> T
get
(ConfigEntry<T> entry) Gets the value of a configuration entry.Retrieves a map containing all configuration entries.getConfigsWithPrefix
(String prefix) Retrieves a map containing configuration entries that have keys with the specified prefix.getRawString
(String key) Retrieves the raw string value associated with the specified configuration key.getRawString
(String key, String defaultValue) Retrieves the raw string value associated with the specified configuration key, providing a default value if the key is not found.loadFromFile
(String name) Loads configurations from a properties file.void
Loads configurations from a map.void
loadFromProperties
(Properties properties) Loads configurations from properties.loadPropertiesFromFile
(File file) Loads properties from a file.<T> void
set
(ConfigEntry<T> entry, T value) Sets the value of a configuration entry.
-
Constructor Details
-
Config
protected Config(boolean loadDefaults) Constructs a Config instance.- Parameters:
loadDefaults
- Set to true if default configurations should be loaded.
-
Config
protected Config()Constructs a Config instance and loads default configurations.
-
-
Method Details
-
loadFromFile
Loads configurations from a properties file.- Parameters:
name
- The name of the properties file.- Returns:
- The Config instance.
- Throws:
Exception
- If there's an issue loading the properties.
-
get
Gets the value of a configuration entry.- Type Parameters:
T
- The type of the configuration value.- Parameters:
entry
- The configuration entry to retrieve.- Returns:
- The value of the configuration entry.
- Throws:
NoSuchElementException
- If the configuration entry is not found.
-
getRawString
Retrieves the raw string value associated with the specified configuration key.- Parameters:
key
- The configuration key for which the raw string value is requested.- Returns:
- The raw string value associated with the given configuration key, or null if the key is not found.
-
getRawString
Retrieves the raw string value associated with the specified configuration key, providing a default value if the key is not found.- Parameters:
key
- The configuration key for which the raw string value is requested.defaultValue
- The default value to be returned if the key is not found.- Returns:
- The raw string value associated with the given configuration key, or the provided default value if the key is not found.
-
getConfigsWithPrefix
Retrieves a map containing configuration entries that have keys with the specified prefix.- Parameters:
prefix
- The prefix that configuration keys should start with.- Returns:
- An unmodifiable map containing configuration entries with keys matching the prefix.
-
getAllConfig
Retrieves a map containing all configuration entries.- Returns:
- An unmodifiable map containing all configuration entries.
-
set
Sets the value of a configuration entry.- Type Parameters:
T
- The type of the configuration value.- Parameters:
entry
- The configuration entry for which the value needs to be set.value
- The new value to be assigned to the configuration entry.
-
loadFromMap
Loads configurations from a map.- Parameters:
map
- The map containing configuration key-value pairs.predicate
- The keys only match the predicate will be loaded to configMap
-
loadFromProperties
Loads configurations from properties.- Parameters:
properties
- The properties object containing configuration key-value pairs.
-
loadPropertiesFromFile
Loads properties from a file.- Parameters:
file
- The properties file to load from.- Returns:
- The loaded properties.
- Throws:
IOException
- If there's an issue loading the properties.
-