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