Package de.exlll.configlib
Class ConfigurationProperties.EnvVarResolutionConfiguration
java.lang.Object
de.exlll.configlib.ConfigurationProperties.EnvVarResolutionConfiguration
- Enclosing class:
ConfigurationProperties
A collection of values used to configure the resolution of environment variables.
-
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns whether the resolution of environment variables should be case-sensitive.disabled()Returns a configuration object that disables the resolution of environment variables.prefix()Returns the string with which the environment variables must begin in order to be resolved.booleanReturns whether environment variables should be resolved.resolveEnvVarsWithPrefix(String prefix, boolean caseSensitive) Returns a configuration object that resolves environment variables that start with the given prefix.
-
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, withcaseSensitiveset tofalse, you can overwrite the values 1 and 2 using the environment variablesALPHA_BE_TAandGA_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 ofbetaandBETAindividually, then you have to setcaseSensitivetotrue. After doing so you can overwrite the values 1 and 2 by using the environment variablesalpha_betaandALPHA_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 namedMY_PREFIX_ALPHA_BE_TA,MY_PREFIX_GA_MMA_DELTA,MY_PREFIX_alpha_beta, andMY_PREFIX_ALPHA_BETA, respectively.
- Parameters:
prefix- string the environment variables have to be prefixed withcaseSensitive- specifies whether the resolution should be case-sensitive- Returns:
- configuration object that resolves environment variables that start with the given prefix
- Throws:
NullPointerException- ifprefixis null
-
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.
-
resolveEnvVars
public boolean resolveEnvVars()Returns whether environment variables should be resolved.- Returns:
- whether environment variables should be resolved
-
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:
-