Class ImmutableAppConfig

java.lang.Object
de.poiu.coat.CoatConfig
de.poiu.coat.example.ImmutableAppConfig
All Implemented Interfaces:
AppConfig

@Generated(value="de.poiu.coat.processor.codegeneration.CodeGenerator", date="2024-03-07T23:24:03.20198587+01:00") public class ImmutableAppConfig extends CoatConfig implements AppConfig
  • Method Details

    • from

      public static ImmutableAppConfig from(Map<String,String> props)
      Create a new ImmutableAppConfig from the given config entries.
      Parameters:
      props - the config entries
      Returns:
      the ImmutableAppConfig created with the given entries
    • from

      public static ImmutableAppConfig from(File file) throws IOException
      Create a new ImmutableAppConfig from the given config file.
      Parameters:
      file - the config file to read
      Returns:
      the ImmutableAppConfig created with the entries from the given file
      Throws:
      IOException - if reading the given file failed
    • from

      public static ImmutableAppConfig from(Properties jup)
      Create a new ImmutableAppConfig from the given config entries.
      Parameters:
      jup - the config entries
      Returns:
      the ImmutableAppConfig created with the given entries
    • fromEnvVars

      public static ImmutableAppConfig fromEnvVars()
      Create a new ImmutableAppConfig 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_HOST will match the config key server.mqttHost.

      Returns:
      the ImmutableAppConfig created with the entries in the current environment variables
    • getName

      public String getName()
      A shorthand name for this application.
      Specified by:
      getName in interface AppConfig
    • getDescription

      public Optional<String> getDescription()
      A short description of the purpose of this application.
      Specified by:
      getDescription in interface AppConfig
    • getListenAddress

      public InetAddress getListenAddress()
      The interfaces to listen on for incoming connections.
      Specified by:
      getListenAddress in interface AppConfig
    • getListenPort

      public int getListenPort()
      The port to listen on for incoming connections.
      Specified by:
      getListenPort in interface AppConfig
    • mqtt

      public MqttConfig mqtt()
      The configuration for the MQTT connection
      Specified by:
      mqtt in interface AppConfig
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • writeExampleConfig

      public static void writeExampleConfig(Writer writer) throws IOException
      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
    • builder

      public static ImmutableAppConfig.Builder builder()
      Create a builder for ImmutableAppConfig instances.

      Call the add and/or addEnvVars methods for specifying the config sources (and the order in which they are applied), then call ImmutableAppConfig.Builder.build() to create the ImmutableAppConfig

      Returns:
      an new ImmutableAppConfig builder