Package: org.codehaus.groovy.transform.tailrec

## [Java] Class VariableAccessReplacer

- org.codehaus.groovy.transform.tailrec.VariableAccessReplacer

-     public class VariableAccessReplacer
      extends Object

  Replace all access to variables and args by new variables. The variable names to replace as well as their replacement name and type have to be configured in nameAndTypeMapping before calling replaceIn().

  The VariableReplacedListener can be set if clients want to react to variable replacement.

- - ### Constructor Summary

    Constructors
    Constructor and description
    `VariableAccessReplacer(Map<String, Map> nameAndTypeMapping)` Creates a replacer with the supplied name/type mapping.
    `VariableAccessReplacer(Map<String, Map> nameAndTypeMapping, VariableReplacedListener listener)` Creates a replacer with the supplied name/type mapping and listener.

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public VariableReplacedListener` | `getListener()` Returns the listener notified when replacements occur.
    `` | `public void` | `replaceIn(ASTNode root)` Replaces matching variable accesses within the supplied AST subtree.
    `` | `public void` | `setListener(VariableReplacedListener listener)` Sets the listener notified when replacements occur.
    `` | `public void` | `setNameAndTypeMapping(Map<String, Map> nameAndTypeMapping)` Sets the variable replacement mapping.

  - ### Inherited Methods Summary

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

- - ### Constructor Detail

    - #### public VariableAccessReplacer(Map<String, Map> nameAndTypeMapping)

      Creates a replacer with the supplied name/type mapping.

      Parameters:
        `nameAndTypeMapping` - the variables to replace and their replacements

    - #### public VariableAccessReplacer(Map<String, Map> nameAndTypeMapping, VariableReplacedListener listener)

      Creates a replacer with the supplied name/type mapping and listener.

      Parameters:
        `nameAndTypeMapping` - the variables to replace and their replacements
        `listener` - the listener notified about replacements

  - ### Method Detail

    - #### public VariableReplacedListener getListener()

      Returns the listener notified when replacements occur.

      Returns:
        the replacement listener

    - #### public void replaceIn(ASTNode root)

      Replaces matching variable accesses within the supplied AST subtree.

      Parameters:
        `root` - the AST subtree to mutate

    - #### public void setListener(VariableReplacedListener listener)

      Sets the listener notified when replacements occur.

      Parameters:
        `listener` - the replacement listener

    - #### public void setNameAndTypeMapping(Map<String, Map> nameAndTypeMapping)

      Sets the variable replacement mapping.

      Parameters:
        `nameAndTypeMapping` - the variables to replace and their replacements