Class EnvironmentVariable.Builder
java.lang.Object
com.inductiveautomation.ignition.common.config.EnvironmentVariable.Builder
- Enclosing class:
- EnvironmentVariable
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()
Create an EnvironmentVariable object matching the composed specifications from the Builder.defaultValue
(String defaultValue) Sets a default (fallback) value for the EnvironmentVariable object if not found.Sets a regex pattern to be used for validating the environment variable value.substitution
(String originalValue, String replacementValue) Add an entry to the substitution map that will be used to translate the retrieved value when resolved.substitution
(Pattern matchingPattern, String replacementValue) Add a Pattern to the substitution map that will be checked for an _explicit_ match and translate the retrieved value when resolved.Register a Transform Function that will be applied after configured substitutions are performed against the resolved Environment Variable value.
-
Field Details
-
key
-
-
Constructor Details
-
Builder
-
-
Method Details
-
pattern
Sets a regex pattern to be used for validating the environment variable value. Default value (if defined) will be used if value does not match expected pattern.- Parameters:
expectedPattern
- is the RegEx Pattern object that will be tested for match against value- Returns:
- Builder object with applied pattern
-
defaultValue
Sets a default (fallback) value for the EnvironmentVariable object if not found.- Parameters:
defaultValue
- is an optional fallback value presented by getValue() if env var not resolved in env.- Returns:
- Builder object with applied default value
-
substitution
Add an entry to the substitution map that will be used to translate the retrieved value when resolved. NOTE: Insertion order of substitutions is not tracked; avoid duplicate substitutions- Parameters:
originalValue
- is the value to substitute when foundreplacementValue
- is the replacement value that will be applied- Returns:
- Builder object with an updated substitution map.
-
substitution
Add a Pattern to the substitution map that will be checked for an _explicit_ match and translate the retrieved value when resolved. NOTE: Insertion order of substitutions is not tracked; avoid duplicate substitutions- Parameters:
matchingPattern
- is a RegEx Pattern object that will be used to test for an explicit/full matchreplacementValue
- is the replacement value that will be applied- Returns:
- Builder object with an updated substitution map.
-
transform
Register a Transform Function that will be applied after configured substitutions are performed against the resolved Environment Variable value. Only one transform function can be registered. WARNING: if null values are possible (i.e. no non-null default specified and env variable not found), then this transform function must handle null String input parameter on its own.- Parameters:
transformFunction
- accepts a String, performs some transformations and returns a String- Returns:
- Builder object with a registered transform function.
-
build
Create an EnvironmentVariable object matching the composed specifications from the Builder.- Returns:
- EnvironmentVariable object that has already resolved its value.
-