Package org.apache.gravitino.config
Class ConfigEntry<T>
java.lang.Object
org.apache.gravitino.config.ConfigEntry<T>
Defines configuration properties.
-
Method Summary
Modifier and TypeMethodDescriptioncheckValue
(Function<T, Boolean> checkValueFunc, String errorMsg) Checks if the user-provided value for the config matches the validator.create()
Creates a new ConfigEntry instance based on this configuration entry with no default value.Creates a new ConfigEntry instance based on this configuration entry with a default value.Creates a new ConfigEntry instance based on this configuration entry with optional value handling.Reads the configuration value.Reduce the values then join them as a string.Split the string to a list, then map each string element to its converted form.ConfigEntry<List<T>>
Converts the configuration value to value list.void
Writes the provided value to the specified properties map.
-
Method Details
-
checkValue
Checks if the user-provided value for the config matches the validator.- Parameters:
checkValueFunc
- The validator of the configuration optionerrorMsg
- The thrown error message if the value is invalid- Returns:
- The current ConfigEntry instance
-
strToSeq
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
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
Converts the configuration value to value list.- Returns:
- The ConfigEntry instance.
-
createWithDefault
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
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
Creates a new ConfigEntry instance based on this configuration entry with no default value.- Returns:
- A new ConfigEntry instance with no default value.
-
readFrom
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
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.
-