Class TemplateVariableProcessor

java.lang.Object
org.sentrysoftware.metricshub.engine.connector.parser.AbstractNodeProcessor
org.sentrysoftware.metricshub.engine.connector.parser.TemplateVariableProcessor

public class TemplateVariableProcessor extends AbstractNodeProcessor
Processes template variables within JSON nodes by substituting placeholders with actual values from a set of connector variables. This processor extends the AbstractNodeProcessor to allow for chained node processing in the context of JSON data parsing and manipulation within the MetricsHub Engine.

It leverages regular expressions to identify placeholders matching a specific pattern and replaces them with corresponding values provided in a map of connector variables. This mechanism facilitates dynamic data manipulation based on the configuration provided at runtime.

  • Constructor Details

    • TemplateVariableProcessor

      public TemplateVariableProcessor(@NonNull @NonNull Map<String,String> connectorVariables, AbstractNodeProcessor next)
      Constructs a new TemplateVariableProcessor with the specified map of connector variables and the next processor in the chain. This constructor initializes the processor with a set of key-value pairs representing the variables to be substituted within JSON templates and optionally, a next AbstractNodeProcessor for further processing.
  • Method Details

    • processNode

      public com.fasterxml.jackson.databind.JsonNode processNode(com.fasterxml.jackson.databind.JsonNode node) throws IOException
      Processes a given Json node by calling JsonNodeUpdater
      Parameters:
      node - The input Json node.
      Returns:
      The processed Json node.
      Throws:
      IOException - thrown by AbstractNodeProcessor