Class ParameterReplacer

java.lang.Object
nz.org.riskscape.rl.ast.ExpressionConverter<List<ParameterToken>>
nz.org.riskscape.pipeline.ast.ParameterReplacer
All Implemented Interfaces:
ExpressionVisitor<List<ParameterToken>,Expression>

public class ParameterReplacer extends ExpressionConverter<List<ParameterToken>>

An ExpressionVisitor that rewrites an expression by replacing any parameters it has found with substitutions from the visitor's map of replacements.

  • Constructor Details

    • ParameterReplacer

      public ParameterReplacer(Map<ParameterToken,Expression> replacements)

      Creates a new ParameterReplacer instance.

      Parameters:
      replacements - A map of ParameterToken to Expressions that are used to rewrite expressions. Whenever a ParameterToken is found in the expression being visited, this map is queried for the found ParameterToken and the mapped Expression replaces the found ParameterToken.

      E.g. The expression foo($bar, baz) + $barry would change to foo(bar_replacement(), baz) + $barry if the replacements map was {$bar: bar_replacement()}

  • Method Details