Package de.poiu.coat.example
Class ImmutableMqttConfig.Builder
java.lang.Object
de.poiu.coat.example.ImmutableMqttConfig.Builder
- Enclosing class:
ImmutableMqttConfig
Builder class for creating new
ImmutableMqttConfig 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
ImmutableMqttConfig
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdd the config entries from the given file to the built ImmutableMqttConfig.Add the config entries from the given Map to the built ImmutableMqttConfig.add(Properties jup) Add the config entries from the given Properties to the built ImmutableMqttConfig.Add the config entries from the current environment variables to the built ImmutableMqttConfig.build()Build a newImmutableMqttConfigwith 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 ImmutableMqttConfig. 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 ImmutableMqttConfig. 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 ImmutableMqttConfig. 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 ImmutableMqttConfig. 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 newImmutableMqttConfigwith the config keys from this Builder.- Returns:
- a new ImmutableMqttConfig
-