Class EnvironmentVariableUtil


  • public class EnvironmentVariableUtil
    extends Object
    This class provides an easy way to get environmental variables. This is mainly to improve testability but also to standardize the way how utPLSQL API and CLI read from environment.

    Variables are obtained from the following scopes in that order (chain breaks as soon as a value is obtained):

    • Properties (System.getProperty())
    • Environment (System.getEnv())
    • Default value

    An empty string is treated the same as null.

    Author:
    pesse
    • Method Detail

      • getEnvValue

        public static String getEnvValue​(String key)
        Returns the value for a given key from environment (see class description)
        Parameters:
        key - Key of environment or property value
        Returns:
        Environment value or null
      • getEnvValue

        public static String getEnvValue​(String key,
                                         @Nullable
                                         String defaultValue)
        Returns the value for a given key from environment or a default value (see class description)
        Parameters:
        key - Key of environment or property value
        defaultValue - Default value if nothing found
        Returns:
        Environment value or defaultValue