Class TemplateHelper

java.lang.Object
io.bdeploy.common.util.TemplateHelper

public class TemplateHelper extends Object
  • Method Details

    • process

      public static List<String> process(List<String> values, VariableResolver valueResolver)
      Resolves all variable references in the given list of strings using the given resolver.
      Parameters:
      values - the raw values, potentially containing variable references.
      valueResolver - knows how to replace references with the actual content
      Returns:
      the resolved strings
    • process

      public static List<String> process(List<String> values, VariableResolver valueResolver, ShouldResolve shouldResolve)
      Asks the given resolver callback whether or not to resolve the variables contained in the given list of strings. The callback can be used to skip resolving of given variables.
      Parameters:
      values - the raw values, potentially containing variable references.
      valueResolver - knows how to replace references with the actual content
      shouldResolve - callback to ask whether or not to resolve the given variable
      Returns:
      the resolved strings
    • process

      public static String process(String value, VariableResolver valueResolver)
      Resolves all variable references in the given string using the given resolver.
      Parameters:
      value - the raw value, potentially containing variable references.
      valueResolver - knows how to replace references with the actual content
      Returns:
      the resolved string
    • process

      public static String process(String value, VariableResolver valueResolver, ShouldResolve shouldResolve)
      Resolves all variable references in the given String, using the given resolver. The callback can be used to skip resolving of given variables.
      Parameters:
      value - the raw value, potentially containing variable references.
      valueResolver - knows how to replace references with the actual content
      shouldResolve - callback to ask whether or not to resolve the given variable
      Returns:
      the resolved string
    • updateReferences

      public static String updateReferences(String value, UnaryOperator<String> processor)
      Processes each template reference in the given input by calling the given processor.

      Whatever result is returned by the processor will be re-inserted *as template variable* (including the pattern start and end markers!) in the string.

    • processFileTemplates

      public static void processFileTemplates(Path path, VariableResolver resolver)
      Parameters:
      path - a folder containing files to recursively read/expand templates/write.
      resolver - the VariableResolver used to resolve all references.