Class EnvironmentVariable.Builder

java.lang.Object
com.inductiveautomation.ignition.common.config.EnvironmentVariable.Builder
Enclosing class:
EnvironmentVariable

public static class EnvironmentVariable.Builder extends Object
  • Field Details

    • key

      public final String key
  • Constructor Details

    • Builder

      public Builder(String envKey)
  • Method Details

    • pattern

      public EnvironmentVariable.Builder pattern(Pattern expectedPattern)
      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

      public EnvironmentVariable.Builder defaultValue(String 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

      public EnvironmentVariable.Builder substitution(String originalValue, String replacementValue)
      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 found
      replacementValue - is the replacement value that will be applied
      Returns:
      Builder object with an updated substitution map.
    • substitution

      public EnvironmentVariable.Builder 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. 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 match
      replacementValue - is the replacement value that will be applied
      Returns:
      Builder object with an updated substitution map.
    • transform

      public EnvironmentVariable.Builder transform(Function<String,String> transformFunction)
      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

      public EnvironmentVariable build()
      Create an EnvironmentVariable object matching the composed specifications from the Builder.
      Returns:
      EnvironmentVariable object that has already resolved its value.