Class ImmutableMqttConfig.Builder

java.lang.Object
de.poiu.coat.example.ImmutableMqttConfig.Builder
Enclosing class:
ImmutableMqttConfig

public static class ImmutableMqttConfig.Builder extends Object
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 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

      public ImmutableMqttConfig.Builder add(File file) throws IOException
      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

      public ImmutableMqttConfig.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_HOST will match the config key server.mqttHost.

      Returns:
      this Builder
    • build

      public ImmutableMqttConfig build()
      Build a new ImmutableMqttConfig with the config keys from this Builder.
      Returns:
      a new ImmutableMqttConfig