Class ImmutableAppConfig.Builder

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

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

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

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

      Returns:
      this Builder
    • build

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