Class ConfigurationProperties.EnvVarResolutionConfiguration

java.lang.Object
de.exlll.configlib.ConfigurationProperties.EnvVarResolutionConfiguration
Enclosing class:
ConfigurationProperties

public static final class ConfigurationProperties.EnvVarResolutionConfiguration extends Object
A collection of values used to configure the resolution of environment variables.
  • Method Details

    • disabled

      Returns a configuration object that disables the resolution of environment variables.
      Returns:
      configuration object that disables the resolution of environment variables.
    • resolveEnvVarsWithPrefix

      public static ConfigurationProperties.EnvVarResolutionConfiguration resolveEnvVarsWithPrefix(String prefix, boolean caseSensitive)
      Returns a configuration object that resolves environment variables that start with the given prefix. Specifying a non-empty prefix that is specific to your project is highly recommended.

      On UNIX systems environment variables are case-sensitive. On Windows they are case-insensitive.

      • If you want to (or have to, because you are on Windows) target the values of your configuration using uppercase environment variables, then you have to disable case-sensitive resolution.

        For example, if you have a YAML configuration with the following content

         alPHA:
           be_ta: 1
         ga_mma:
           dELTa: 2
         
        then, with caseSensitive set to false, you can overwrite the values 1 and 2 using the environment variables ALPHA_BE_TA and GA_MMA_DELTA, respectively.
      • If your configuration contains paths that differ only in their case, but are otherwise the same, and if you want to target these paths individually, then you have to enable case-sensitive resolution.

        For example, if you have a YAML configuration with the following content

         alpha:
           beta: 1
         ALPHA:
           BETA: 2
         
        and you want to target the values of beta and BETA individually, then you have to set caseSensitive to true. After doing so you can overwrite the values 1 and 2 by using the environment variables alpha_beta and ALPHA_BETA, respectively.
      • If you specify a non-empty prefix, then all variables that you want to be resolved have to start with that prefix. For example, if you choose MY_PREFIX_ as your prefix, then the four variables listed above have to be named MY_PREFIX_ALPHA_BE_TA, MY_PREFIX_GA_MMA_DELTA, MY_PREFIX_alpha_beta, and MY_PREFIX_ALPHA_BETA, respectively.
      Parameters:
      prefix - string the environment variables have to be prefixed with
      caseSensitive - specifies whether the resolution should be case-sensitive
      Returns:
      configuration object that resolves environment variables that start with the given prefix
      Throws:
      NullPointerException - if prefix is null
    • resolveEnvVars

      public boolean resolveEnvVars()
      Returns whether environment variables should be resolved.
      Returns:
      whether environment variables should be resolved
    • prefix

      public String prefix()
      Returns the string with which the environment variables must begin in order to be resolved.
      Returns:
      the string environment variables have to begin with to be resolved
      See Also:
    • caseSensitive

      public boolean caseSensitive()
      Returns whether the resolution of environment variables should be case-sensitive.
      Returns:
      whether the resolution of environment variables should be case-sensitive
      See Also: