Class SystemEnvProperties
- All Implemented Interfaces:
Serializable
,Cloneable
,Map<Object,
Object>
An utility class to resolve the value of a key based on the environment variables and system properties available at runtime. In most cases, you do not want to resolve whatever system variable is available at runtime but specify which ones can be used when resolving placeholders.
To resolve to an environment variable, the key must have a format like env.<key>
where key
is the name of an environment variable.
For system properties, there is no specific format and the value is resolved from a system property that matches the key.
- Author:
- Stian Thorgersen
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final SystemEnvProperties
An variation ofSystemEnvProperties
that gives unrestricted access to any system variable available at runtime.Fields inherited from class java.util.Properties
defaults
-
Constructor Summary
ConstructorDescriptionSystemEnvProperties
(Set<String> allowedSystemVariables) Creates a new instance where system variables where only specific keys can be resolved from system variables. -
Method Summary
Modifier and TypeMethodDescriptiongetProperty
(String key) getProperty
(String key, String defaultValue) protected boolean
Methods inherited from class java.util.Properties
clear, clone, compute, computeIfAbsent, computeIfPresent, contains, containsKey, containsValue, elements, entrySet, equals, forEach, get, getOrDefault, hashCode, isEmpty, keys, keySet, list, list, load, load, loadFromXML, merge, propertyNames, put, putAll, putIfAbsent, rehash, remove, remove, replace, replace, replaceAll, save, setProperty, size, store, store, storeToXML, storeToXML, storeToXML, stringPropertyNames, toString, values
-
Field Details
-
UNFILTERED
An variation of
SystemEnvProperties
that gives unrestricted access to any system variable available at runtime. Most of the time you don't want to use this class but favor creating aSystemEnvProperties
instance that filters which system variables should be available at runtime.
-
-
Constructor Details
-
SystemEnvProperties
Creates a new instance where system variables where only specific keys can be resolved from system variables.- Parameters:
allowedSystemVariables
- the keys of system variables that should be available at runtime
-
-
Method Details
-
getProperty
- Overrides:
getProperty
in classProperties
-
getProperty
- Overrides:
getProperty
in classProperties
-
isAllowed
-