Package de.poiu.coat.example
Class ImmutableAppConfig.Builder
java.lang.Object
de.poiu.coat.example.ImmutableAppConfig.Builder
- Enclosing class:
ImmutableAppConfig
Builder class for creating new
ImmutableAppConfig instances.
Call the add and/or addEnvVars methods for specifying the config
sources (and the order in which they are applied), then call build() to create the
ImmutableAppConfig
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdd the config entries from the given file to the built ImmutableAppConfig.Add the config entries from the given Map to the built ImmutableAppConfig.add(Properties jup) Add the config entries from the given Properties to the built ImmutableAppConfig.Add the config entries from the current environment variables to the built ImmutableAppConfig.build()Build a newImmutableAppConfigwith the config keys from this Builder.
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
add
Add the config entries from the given Map to the built ImmutableAppConfig. Already existing config entries with the same keys will be overwritten.- Parameters:
map- the config entries to add- Returns:
- this Builder
-
add
Add the config entries from the given file to the built ImmutableAppConfig. 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 ImmutableAppConfig. 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 ImmutableAppConfig. 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
-
build
Build a newImmutableAppConfigwith the config keys from this Builder.- Returns:
- a new ImmutableAppConfig
-