-
Method Summary
Modifier and TypeMethodDescriptionAdd the config entries from the given file to the built AppConfig.Add the config entries from the given Map to the built AppConfig.add(Properties jup) Add the config entries from the given Properties to the built AppConfig.Add the config entries from the current environment variables to the built AppConfig.build()Build a newAppConfigwith the config keys from this Builder.static AppConfigBuildercreate()Create a builder forAppConfiginstances.static AppConfigCreate a new AppConfig from the given config file.static AppConfigCreate a new AppConfig from the given config entries.static AppConfigfrom(Properties jup) Create a new AppConfig from the given config entries.static AppConfigCreate a new AppConfig from the current environment variables.static voidwriteExampleConfig(Writer writer) Write an example config file to the given Writer.Methods inherited from class de.poiu.coat.CoatConfigBuilder
convertPrimitive, convertValue, createMissingKeyFailure, createUnparsableValueFailure, filterByAndStripPrefix, get, get, getArray, getArrayOrDefault, getBoolean, getBooleanOrDefault, getDouble, getDoubleOrDefault, getInt, getIntOrDefault, getList, getListOrDefault, getLong, getLongOrDefault, getOptional, getOptionalDouble, getOptionalDoubleOrDefault, getOptionalInt, getOptionalIntOrDefault, getOptionalLong, getOptionalLongOrDefault, getOptionalOrDefault, getOptionalString, getOrDefault, getParamStrings, getSet, getSetOrDefault, getString, getStringOrDefault, hasPrefix, registerCustomConverter, registerCustomListParser, toMap, toMap, tryConversion, validate
-
Method Details
-
from
Create a new AppConfig from the given config entries.- Parameters:
props- the config entries- Returns:
- the AppConfig created with the given entries
- Throws:
ConfigValidationException
-
from
Create a new AppConfig from the given config file.- Parameters:
file- the config file to read- Returns:
- the AppConfig created with the entries from the given file
- Throws:
IOException- if reading the given file failedConfigValidationException
-
from
Create a new AppConfig from the given config entries.- Parameters:
jup- the config entries- Returns:
- the AppConfig created with the given entries
- Throws:
ConfigValidationException
-
fromEnvVars
Create a new AppConfig from the current environment variables.Since the allowed characters for environment variables are much more restricted than Coat config keys, a relaxed mapping is applied.
Dots and hyphens are treated as underscores. Also uppercase characters in config keys are preceded by an underscore (to convert camelCase to UPPER_CASE). Comparison between the environment variables and the config keys is done case insensitively.
For example the environment variable
SERVER_MQTT_HOSTwill match the config keyserver.mqttHost.- Returns:
- the AppConfig created with the entries in the current environment variables
- Throws:
ConfigValidationException
-
create
-
add
Add the config entries from the given Map to the built AppConfig. Already existing config entries with the same keys will be overwritten.- Overrides:
addin classde.poiu.coat.CoatConfigBuilder- Parameters:
map- the config entries to add- Returns:
- this Builder
-
add
Add the config entries from the given file to the built AppConfig. Already existing config entries with the same keys will be overwritten.- Parameters:
file- the file with the config entries to add- Returns:
- this Builder
- Throws:
IOException- if reading the config file failed
-
add
Add the config entries from the given Properties to the built AppConfig. Already existing config entries with the same keys will be overwritten.- Parameters:
jup- the config entries to add- Returns:
- this Builder
-
addEnvVars
Add the config entries from the current environment variables to the built AppConfig. Already existing config entries with the same keys will be overwritten.Since the allowed characters for environment variables are much more restricted than Coat config keys, a relaxed mapping is applied.
Dots and hyphens are treated as underscores. Also uppercase characters in config keys are preceded by an underscore (to convert camelCase to UPPER_CASE). Comparison between the environment variables and the config keys is done case insensitively.
For example the environment variable
SERVER_MQTT_HOSTwill match the config keyserver.mqttHost.- Returns:
- this Builder
-
writeExampleConfig
Write an example config file to the given Writer.- Parameters:
writer- the Writer to write to- Throws:
IOException- if writing the example config file fails
-
build
Build a newAppConfigwith the config keys from this Builder.- Returns:
- a new AppConfig
- Throws:
ConfigValidationException
-