public class ConfigEntry<T>
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
ConfigEntry<T> |
checkValue(java.util.function.Function<T,java.lang.Boolean> checkValueFunc,
java.lang.String errorMsg)
Checks if the user-provided value for the config matches the validator.
|
ConfigEntry<T> |
create()
Creates a new ConfigEntry instance based on this configuration entry with no default value.
|
ConfigEntry<T> |
createWithDefault(T t)
Creates a new ConfigEntry instance based on this configuration entry with a default value.
|
ConfigEntry<java.util.Optional<T>> |
createWithOptional()
Creates a new ConfigEntry instance based on this configuration entry with optional value
handling.
|
T |
readFrom(java.util.Map<java.lang.String,java.lang.String> properties)
Reads the configuration value.
|
java.lang.String |
seqToStr(java.util.List<T> seq,
java.util.function.Function<T,java.lang.String> converter)
Reduce the values then join them as a string.
|
java.util.List<T> |
strToSeq(java.lang.String str,
java.util.function.Function<java.lang.String,T> converter)
Split the string to a list, then map each string element to its converted form.
|
ConfigEntry<java.util.List<T>> |
toSequence()
Converts the configuration value to value list.
|
void |
writeTo(java.util.Map<java.lang.String,java.lang.String> properties,
T value)
Writes the provided value to the specified properties map.
|
public ConfigEntry<T> checkValue(java.util.function.Function<T,java.lang.Boolean> checkValueFunc, java.lang.String errorMsg)
checkValueFunc
- The validator of the configuration optionerrorMsg
- The thrown error message if the value is invalidpublic java.util.List<T> strToSeq(java.lang.String str, java.util.function.Function<java.lang.String,T> converter)
str
- The string form of the value list from the conf entry.converter
- The orignal ConfigEntry valueConverter.public java.lang.String seqToStr(java.util.List<T> seq, java.util.function.Function<T,java.lang.String> converter)
seq
- The sequence of the value list from the conf entry.converter
- The orignal ConfigEntry stringConverter.public ConfigEntry<java.util.List<T>> toSequence()
public ConfigEntry<T> createWithDefault(T t)
t
- The default value to be used when no value is provided.public ConfigEntry<java.util.Optional<T>> createWithOptional()
public ConfigEntry<T> create()
public T readFrom(java.util.Map<java.lang.String,java.lang.String> properties) throws java.util.NoSuchElementException
properties
- The map containing the configuration properties.java.util.NoSuchElementException
- If the configuration value is not found.public void writeTo(java.util.Map<java.lang.String,java.lang.String> properties, T value)
properties
- The map to write the configuration property to.value
- The value of the configuration entry.