java.lang.Object
edu.iu.IuRuntimeEnvironment
Provides basic utilities for inspecting the runtime environment.
Runtime properties should be used sparingly, sufficient only to support bootstrapping the application's configuration management layer.
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
Checks for the presence of a system property, then defaults to an environment variable if not set.static <T> T
Checks for the presence of a system property, then defaults to an environment variable if not set.static String
envOptional
(String name) Checks for the presence of a system property, then defaults to an environment variable if not set.static <T> T
envOptional
(String name, Function<String, T> textToValueFunction) Checks for the presence of a system property, then defaults to an environment variable if not set.
-
Method Details
-
envOptional
Checks for the presence of a system property, then defaults to an environment variable if not set. If the system property is set, but blank, returns null.- Type Parameters:
T
- value type- Parameters:
name
- property name. Must start with a letter and contain only letters, digits, '_', '-', and '.'. Will be converted to upper case, '.' and '-' replaced with '_', for checking the environment.textToValueFunction
- converts a non-null property value to the target type; not applied to null- Returns:
- system property value if set, environment variable if not set, null if blank or both are missing
-
envOptional
Checks for the presence of a system property, then defaults to an environment variable if not set. If the system property is set, but blank, returns null.- Parameters:
name
- property name. Must start with a letter and contain only letters, digits, '_', '-', and '.'. Will be converted to upper case, '.' and '-' replaced with '_', for checking the environment.- Returns:
- system property value if set, environment variable if not set, null if blank or both are missing
-
env
Checks for the presence of a system property, then defaults to an environment variable if not set.- Type Parameters:
T
- value type- Parameters:
name
- property nametextToValueFunction
- converts a non-null property value to the target type; not applied to null- Returns:
- system property value if set, environment variable if not set
- Throws:
NullPointerException
- if the system property is blank or both are missing
-
env
Checks for the presence of a system property, then defaults to an environment variable if not set.- Parameters:
name
- property name- Returns:
- system property value if set, environment variable if not set
- Throws:
NullPointerException
- if the system property is blank or both are missing
-