Package org.utplsql.api
Class EnvironmentVariableUtil
- java.lang.Object
-
- org.utplsql.api.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 Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringgetEnvValue(String key)Returns the value for a given key from environment (see class description)static StringgetEnvValue(String key, String defaultValue)Returns the value for a given key from environment or a default value (see class description)
-
-
-
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 valuedefaultValue- Default value if nothing found- Returns:
- Environment value or defaultValue
-
-