Class ImmutableMqttConfig

java.lang.Object
de.poiu.coat.CoatConfig
de.poiu.coat.example.ImmutableMqttConfig
All Implemented Interfaces:
MqttConfig

@Generated(value="de.poiu.coat.processor.codegeneration.CodeGenerator", date="2024-02-28T22:55:19.92188975+01:00") public class ImmutableMqttConfig extends CoatConfig implements MqttConfig
  • Method Details

    • from

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

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

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

      public static ImmutableMqttConfig fromEnvVars()
      Create a new ImmutableMqttConfig 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 ImmutableMqttConfig created with the entries in the current environment variables
    • getClientId

      public Optional<String> getClientId()
      The clientId to send to the MQTT broker.
      Specified by:
      getClientId in interface MqttConfig
    • getBrokerAddresses

      public InetAddress[] getBrokerAddresses()
      The address(es) of the MQTT broker.
      Specified by:
      getBrokerAddresses in interface MqttConfig
    • getPort

      public int getPort()
      The port to communicate with the MQTT broker.
      Specified by:
      getPort in interface MqttConfig
    • username

      public Optional<String> username()
      The username to connect to the MQTT broker.
      Specified by:
      username in interface MqttConfig
    • password

      public Optional<String> password()
      The password to connect to the MQTT broker.
      Specified by:
      password in interface MqttConfig
    • 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 ImmutableMqttConfig.Builder builder()
      Create a builder for ImmutableMqttConfig instances.

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

      Returns:
      an new ImmutableMqttConfig builder