MqttConfig instances.
Create the builder by calling create(). Then 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 MqttConfig.
-
Method Summary
Modifier and TypeMethodDescriptionAdd the config entries from the given file to the built MqttConfig.Add the config entries from the given Map to the built MqttConfig.add(Properties jup) Add the config entries from the given Properties to the built MqttConfig.Add the config entries from the current environment variables to the built MqttConfig.build()Build a newMqttConfigwith the config keys from this Builder.static MqttConfigBuildercreate()Create a builder forMqttConfiginstances.static MqttConfigCreate a new MqttConfig from the given config file.static MqttConfigCreate a new MqttConfig from the given config entries.static MqttConfigfrom(Properties jup) Create a new MqttConfig from the given config entries.static MqttConfigCreate a new MqttConfig 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 MqttConfig from the given config entries.- Parameters:
props- the config entries- Returns:
- the MqttConfig created with the given entries
- Throws:
ConfigValidationException
-
from
Create a new MqttConfig from the given config file.- Parameters:
file- the config file to read- Returns:
- the MqttConfig created with the entries from the given file
- Throws:
IOException- if reading the given file failedConfigValidationException
-
from
Create a new MqttConfig from the given config entries.- Parameters:
jup- the config entries- Returns:
- the MqttConfig created with the given entries
- Throws:
ConfigValidationException
-
fromEnvVars
Create a new MqttConfig 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 MqttConfig created with the entries in the current environment variables
- Throws:
ConfigValidationException
-
create
Create a builder forMqttConfiginstances.Call the
addand/oraddEnvVarsmethods for specifying the config sources (and the order in which they are applied), then callbuild()to create the MqttConfig- Returns:
- a new MqttConfigBuilder
-
add
Add the config entries from the given Map to the built MqttConfig. 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 MqttConfig. 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 MqttConfig. 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 MqttConfig. 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 newMqttConfigwith the config keys from this Builder.- Returns:
- a new MqttConfig
- Throws:
ConfigValidationException
-