Class EnvironmentVariable

java.lang.Object
com.inductiveautomation.ignition.common.config.EnvironmentVariable

public class EnvironmentVariable extends Object
EnvironmentVariable assists with resolving environment variables and provides some utility behavior for detecting presence, resolving values, and performing simple value translation/mapping.
  • Method Details

    • getEnv

      @Nullable public static String getEnv(String key)
      Helper method to retrieve environment variable value based on a specified key (name)
      Parameters:
      key - the name of the environment variable to retrieve
      Returns:
      The environment variable value as a String, possibly Null
    • getEnv

      public static Map<String,String> getEnv()
    • getName

      public String getName()
      Returns:
      the base name of the environment variable
    • getNameFile

      public String getNameFile()
      Returns:
      the _FILE suffix name of the environment variable (will attempt to resolve first)
    • getValue

      @Nullable public String getValue()
      Returns:
      substituted (if applicable) value of the resolved env var, or default if defined, otherwise null
    • isFoundInEnv

      public boolean isFoundInEnv()
      Checks if env var was found in environment. Use this to check if the environment variable was defined with any value. If you also want to determine if the fallback value was applied due to an expected pattern mismatch, use isDefaultValueUsed().
      Returns:
      true if environment variable was found in the environment and matches an applied pattern (if applicable)
    • isDefaultValueUsed

      public boolean isDefaultValueUsed()
      Checks if a fallback default value was applied during environment variable resolution due to either a missing environment variable or an expected pattern mis-match.
      Returns:
      true if fallback default was applied
    • newEnvVar

      public static EnvironmentVariable.Builder newEnvVar(String envKey)
      Create an EnvironmentVariable builder with environment variable name `envKey`
      Parameters:
      envKey - name of the environment variable to be resolved
      Returns:
      a Builder for EnvironmentVariable
    • newEnvVars

      public static EnvironmentVariable.BulkBuilder newEnvVars(Pattern envKeyPattern)
      Create an EnvironmentVariable bulk builder to retrieve all env vars matching a RegEx Pattern
      Parameters:
      envKeyPattern - RegEx Pattern object that will be used to match available Env Vars
      Returns:
      a BulkBuilder for EnvironmentVariable
    • newEnvVars

      public static EnvironmentVariable.BulkBuilder newEnvVars(List<Pattern> envKeyPatterns)