Package org.codehaus.groovy.ast.tools
Class ClosureUtils
java.lang.Object
org.codehaus.groovy.ast.tools.ClosureUtils
Handy methods when working with Closure AST data structures.
- 
Constructor Summary
Constructors - 
Method Summary
Modifier and TypeMethodDescriptionstatic StringconvertClosureToSource(ReaderSource readerSource, ClosureExpression expression) Converts a ClosureExpression into the String source.static Parameter[]static StringgetResolveStrategyName(int resolveStrategy) Returns the constant name associated with the given resolve strategy.static booleanstatic booleanDoes the Closure have a single char-like (char or Character) argument.static booleanDoes the Closure have a single String argument. 
- 
Constructor Details
- 
ClosureUtils
public ClosureUtils() 
 - 
 - 
Method Details
- 
convertClosureToSource
public static String convertClosureToSource(ReaderSource readerSource, ClosureExpression expression) throws Exception Converts a ClosureExpression into the String source.- Parameters:
 readerSource- a sourceexpression- a closure. Can't be null- Returns:
 - the source the closure was created from
 - Throws:
 IllegalArgumentException- when expression is nullException- when closure can't be read from source
 - 
hasSingleCharacterArg
Does the Closure have a single char-like (char or Character) argument.- Parameters:
 c- a Closure- Returns:
 - true if it has exactly one argument and the type is char or Character
 
 - 
hasSingleStringArg
Does the Closure have a single String argument.- Parameters:
 c- a Closure- Returns:
 - true if it has exactly one argument and the type is String
 
 - 
hasImplicitParameter
- Returns:
 - true if the ClosureExpression has an implicit 'it' parameter
 
 - 
getParametersSafe
- Returns:
 - the parameters for the ClosureExpression
 
 - 
getResolveStrategyName
Returns the constant name associated with the given resolve strategy.- Since:
 - 3.0.5
 
 
 -