Class VariableStringResolver


  • public final class VariableStringResolver
    extends Object
    Resolve variables in a string referencing entries from a map.
    • Constructor Detail

      • VariableStringResolver

        public VariableStringResolver​(ValueProviderGlobalContext valueProviderGlobalContext,
                                      VariableMapResolver variableMapResolver)
        Parameters:
        valueProviderGlobalContext - Value provider global context
        variableMapResolver - Variable map resolver
    • Method Detail

      • resolveString

        public String resolveString​(String value,
                                    Map<String,​Object> variables)
        Replace variable placeholders in a string with syntax ${key} with values from a map. The variables can recursively reference each other. All escaped variables are deescaped.
        Parameters:
        value - Value with variable placeholders
        variables - Variable map
        Returns:
        Value with variable placeholders resolved.
        Throws:
        IllegalArgumentException - when a variable name could not be resolve.d
      • resolve

        public Object resolve​(String value,
                              Map<String,​Object> variables)
        Replace variable placeholders in a string with syntax ${key} with values from a map. The variables can recursively reference each other. All escaped variables are deescaped.
        Parameters:
        value - Value with variable placeholders
        variables - Variable map
        Returns:
        Value with variable placeholders resolved.
        Throws:
        IllegalArgumentException - when a variable name could not be resolve.d
      • resolveString

        public String resolveString​(String value,
                                    Map<String,​Object> variables,
                                    boolean deescapeVariables)
        Replace variable placeholders in a string with syntax ${key} with values from a map. The variables can recursively reference each other.
        Parameters:
        value - Value with variable placeholders
        variables - Variable map
        deescapeVariables - If true, deescape(String) is applied to the result string
        Returns:
        Value with variable placeholders resolved.
        Throws:
        IllegalArgumentException - when a variable name could not be resolve.d
      • resolve

        public Object resolve​(String value,
                              Map<String,​Object> variables,
                              boolean deescapeVariables)
        Replace variable placeholders in a string with syntax ${key} with values from a map. The variables can recursively reference each other.
        Parameters:
        value - Value with variable placeholders
        variables - Variable map
        deescapeVariables - If true, deescape(String) is applied to the result string
        Returns:
        Value with variable placeholders resolved.
        Throws:
        IllegalArgumentException - when a variable name could not be resolve.d
      • deescape

        public String deescape​(String value)
        De-escapes all escaped variables in the given string.
        Parameters:
        value - String that may contain escaped variable references (starting with \$)
        Returns:
        String with de-escaped variable references.
      • hasValueProviderReference

        public static boolean hasValueProviderReference​(String value)
        Checks if the given string contains any reference to a variable from a value provider.
        Parameters:
        value - Value string
        Returns:
        true if a value provider reference was found.