Class ConfigEntry<T>

java.lang.Object
org.apache.gravitino.config.ConfigEntry<T>

public class ConfigEntry<T> extends Object
Defines configuration properties.
  • Method Details

    • checkValue

      public ConfigEntry<T> checkValue(Function<T,Boolean> checkValueFunc, String errorMsg)
      Checks if the user-provided value for the config matches the validator.
      Parameters:
      checkValueFunc - The validator of the configuration option
      errorMsg - The thrown error message if the value is invalid
      Returns:
      The current ConfigEntry instance
    • strToSeq

      public List<T> strToSeq(String str, Function<String,T> converter)
      Split the string to a list, then map each string element to its converted form. Leading/trailing whitespace of the input and each element will be trimmed, and blank elements will be ignored before conversion.

      Examples:

      
       strToSeq(null, converter) = []
       strToSeq("   ", converter) = []
       strToSeq("A,B,C", converter) = ["A", "B", "C"]
       strToSeq(" A, B , ,C,   ,D ", converter) = ["A", "B", "C", "D"]
       strToSeq(" AB, B C, ,D,   , E F ", converter) = ["AB", "B C", "D", "E F"]
       
      Parameters:
      str - The string form of the value list from the conf entry.
      converter - The original ConfigEntry valueConverter.
      Returns:
      The list of converted type.
    • seqToStr

      public String seqToStr(List<T> seq, Function<T,String> converter)
      Reduce the values then join them as a string.
      Parameters:
      seq - The sequence of the value list from the conf entry.
      converter - The original ConfigEntry stringConverter.
      Returns:
      The converted string.
    • toSequence

      public ConfigEntry<List<T>> toSequence()
      Converts the configuration value to value list.
      Returns:
      The ConfigEntry instance.
    • createWithDefault

      public ConfigEntry<T> createWithDefault(T t)
      Creates a new ConfigEntry instance based on this configuration entry with a default value.
      Parameters:
      t - The default value to be used when no value is provided.
      Returns:
      A new ConfigEntry instance with the specified default value.
    • createWithOptional

      public ConfigEntry<Optional<T>> createWithOptional()
      Creates a new ConfigEntry instance based on this configuration entry with optional value handling.
      Returns:
      A new ConfigEntry instance that works with optional values.
    • create

      public ConfigEntry<T> create()
      Creates a new ConfigEntry instance based on this configuration entry with no default value.
      Returns:
      A new ConfigEntry instance with no default value.
    • readFrom

      public T readFrom(Map<String,String> properties) throws NoSuchElementException
      Reads the configuration value. If the configuration value is not found, it will try to find the value from the alternatives,which means that newer configurations have higher priority over deprecated ones.
      Parameters:
      properties - The map containing the configuration properties.
      Returns:
      The value of the configuration entry.
      Throws:
      NoSuchElementException - If the configuration value is not found.
    • writeTo

      public void writeTo(Map<String,String> properties, T value)
      Writes the provided value to the specified properties map.
      Parameters:
      properties - The map to write the configuration property to.
      value - The value of the configuration entry.