Package org.codehaus.groovy.transform.tailrec

# Class VariableExpressionTransformer

java.lang.Object
org.codehaus.groovy.transform.tailrec.VariableExpressionTransformer

All Implemented Interfaces:
  `ExpressionTransformer`

public class VariableExpressionTransformer extends Object implements ExpressionTransformer
An expression transformer used in the process of replacing the access to variables

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `VariableExpressionTransformer(Closure<Boolean> when, Closure<VariableExpression> replaceWith)`
  Creates a transformer with the supplied predicate and replacement strategy.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Closure<VariableExpression>`
  `getReplaceWith()`
  Returns the closure that creates replacement variable expressions.
  `Closure<Boolean>`
  `getWhen()`
  Returns the predicate that decides whether a variable expression should be replaced.
  `void`
  `setReplaceWith(Closure<VariableExpression> replaceWith)`
  Sets the closure that creates replacement variable expressions.
  `void`
  `setWhen(Closure<Boolean> when)`
  Sets the predicate that decides whether a variable expression should be replaced.
  `Expression`
  `transform(Expression expr)`
  Transforms the given expression.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### VariableExpressionTransformer

    public VariableExpressionTransformer(Closure<Boolean> when, Closure<VariableExpression> replaceWith)
    Creates a transformer with the supplied predicate and replacement strategy.
    Parameters:
      `when` - decides whether a variable expression should be replaced
      `replaceWith` - creates the replacement variable expression

- ## Method Details

  - ### transform

    public Expression transform(Expression expr)
    Transforms the given expression.
    Specified by:
      `transform` in interface `ExpressionTransformer`
    Parameters:
      `expr` - the expression to transform, may be null
    Returns:
      the transformed expression, may be the same instance, a new instance, or null

  - ### getWhen

    public Closure<Boolean> getWhen()
    Returns the predicate that decides whether a variable expression should be replaced.
    Returns:
      the replacement predicate

  - ### setWhen

    public void setWhen(Closure<Boolean> when)
    Sets the predicate that decides whether a variable expression should be replaced.
    Parameters:
      `when` - the replacement predicate

  - ### getReplaceWith

    public Closure<VariableExpression> getReplaceWith()
    Returns the closure that creates replacement variable expressions.
    Returns:
      the replacement closure

  - ### setReplaceWith

    public void setReplaceWith(Closure<VariableExpression> replaceWith)
    Sets the closure that creates replacement variable expressions.
    Parameters:
      `replaceWith` - the replacement closure