Class Config

java.lang.Object
org.apache.gravitino.Config

public abstract class Config extends Object
The Config class is responsible for managing configuration settings.
  • 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

      public Config loadFromFile(String name) throws Exception
      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

      public <T> T get(ConfigEntry<T> entry) throws NoSuchElementException
      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

      public String getRawString(String key)
      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

      public String 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.
      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

      public Map<String,String> getConfigsWithPrefix(String prefix)
      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

      public Map<String,String> getAllConfig()
      Retrieves a map containing all configuration entries.
      Returns:
      An unmodifiable map containing all configuration entries.
    • set

      public <T> void set(ConfigEntry<T> entry, T value)
      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

      public void loadFromMap(Map<String,String> map, Predicate<String> predicate)
      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

      public void loadFromProperties(Properties properties)
      Loads configurations from properties.
      Parameters:
      properties - The properties object containing configuration key-value pairs.
    • loadPropertiesFromFile

      public Properties loadPropertiesFromFile(File file) throws IOException
      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.