Package: org.codehaus.groovy.transform.tailrec

## [Java] Class VariableExpressionTransformer

- org.codehaus.groovy.transform.tailrec.VariableExpressionTransformer

- All Implemented Interfaces and Traits:
    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 and description
    `VariableExpressionTransformer(Closure<Boolean> when, Closure<VariableExpression> replaceWith)` Creates a transformer with the supplied predicate and replacement strategy.

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public Closure<VariableExpression>` | `getReplaceWith()` Returns the closure that creates replacement variable expressions.
    `` | `public Closure<Boolean>` | `getWhen()` Returns the predicate that decides whether a variable expression should be replaced.
    `` | `public void` | `setReplaceWith(Closure<VariableExpression> replaceWith)` Sets the closure that creates replacement variable expressions.
    `` | `public void` | `setWhen(Closure<Boolean> when)` Sets the predicate that decides whether a variable expression should be replaced.
    `` | `public Expression` | `transform(Expression expr)` * Transforms the given expression. * * Parameters: `expression` - the expression to transform, may be null * Returns: the transformed expression, may be the same instance, a new instance, or null

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Object` | `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### 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 Detail

    - #### public Closure<VariableExpression> getReplaceWith()

      Returns the closure that creates replacement variable expressions.

      Returns:
        the replacement closure

    - #### public Closure<Boolean> getWhen()

      Returns the predicate that decides whether a variable expression should be replaced.

      Returns:
        the replacement predicate

    - #### public void setReplaceWith(Closure<VariableExpression> replaceWith)

      Sets the closure that creates replacement variable expressions.

      Parameters:
        `replaceWith` - the replacement closure

    - #### public void setWhen(Closure<Boolean> when)

      Sets the predicate that decides whether a variable expression should be replaced.

      Parameters:
        `when` - the replacement predicate

    - #### public Expression transform(Expression expr)

      * Transforms the given expression. * *

      Parameters:
        `expression` - the expression to transform, may be null *
      Returns:
        the transformed expression, may be the same instance, a new instance, or null