Class VariableExpressionTransformer
java.lang.Object
org.codehaus.groovy.transform.tailrec.VariableExpressionTransformer
- All Implemented Interfaces:
ExpressionTransformer
An expression transformer used in the process of replacing the access to variables
-
Constructor Summary
ConstructorsConstructorDescriptionVariableExpressionTransformer(Closure<Boolean> when, Closure<VariableExpression> replaceWith) Creates a transformer with the supplied predicate and replacement strategy. -
Method Summary
Modifier and TypeMethodDescriptionReturns the closure that creates replacement variable expressions.getWhen()Returns the predicate that decides whether a variable expression should be replaced.voidsetReplaceWith(Closure<VariableExpression> replaceWith) Sets the closure that creates replacement variable expressions.voidSets the predicate that decides whether a variable expression should be replaced.transform(Expression expr) Transforms the given expression.
-
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 replacedreplaceWith- creates the replacement variable expression
-
-
Method Details
-
transform
Transforms the given expression.- Specified by:
transformin interfaceExpressionTransformer- Parameters:
expr- the expression to transform, may be null- Returns:
- the transformed expression, may be the same instance, a new instance, or null
-
getWhen
Returns the predicate that decides whether a variable expression should be replaced.- Returns:
- the replacement predicate
-
setWhen
Sets the predicate that decides whether a variable expression should be replaced.- Parameters:
when- the replacement predicate
-
getReplaceWith
Returns the closure that creates replacement variable expressions.- Returns:
- the replacement closure
-
setReplaceWith
Sets the closure that creates replacement variable expressions.- Parameters:
replaceWith- the replacement closure
-