Package org.codehaus.groovy.ast.tools
Class ClosureUtils
java.lang.Object
org.codehaus.groovy.ast.tools.ClosureUtils
public class ClosureUtils
extends java.lang.Object
Handy methods when working with Closure AST data structures.
- 
Constructor SummaryConstructors Constructor Description ClosureUtils()
- 
Method SummaryModifier and Type Method Description static java.lang.StringconvertClosureToSource(ReaderSource readerSource, ClosureExpression expression)Converts a ClosureExpression into the String source.static Parameter[]getParametersSafe(ClosureExpression ce)static java.lang.StringgetResolveStrategyName(int resolveStrategy)Returns the constant name associated with the given resolve strategy.static booleanhasImplicitParameter(ClosureExpression ce)static booleanhasSingleCharacterArg(Closure c)Does the Closure have a single char-like (char or Character) argument.static booleanhasSingleStringArg(Closure c)Does the Closure have a single String argument.Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
- 
Constructor Details- 
ClosureUtilspublic ClosureUtils()
 
- 
- 
Method Details- 
convertClosureToSourcepublic static java.lang.String convertClosureToSource(ReaderSource readerSource, ClosureExpression expression) throws java.lang.ExceptionConverts a ClosureExpression into the String source.- Parameters:
- readerSource- a source
- expression- a closure. Can't be null
- Returns:
- the source the closure was created from
- Throws:
- java.lang.IllegalArgumentException- when expression is null
- java.lang.Exception- when closure can't be read from source
 
- 
hasSingleCharacterArgDoes 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
 
- 
hasSingleStringArgDoes 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
 
- 
getResolveStrategyNamepublic static java.lang.String getResolveStrategyName(int resolveStrategy)Returns the constant name associated with the given resolve strategy.- Since:
- 3.0.5
 
 
-