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 Summary
Constructors Constructor Description ClosureUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.String
convertClosureToSource(ReaderSource readerSource, ClosureExpression expression)
Converts a ClosureExpression into the String source.static boolean
hasSingleCharacterArg(Closure c)
Does the Closure have a single char-like (char or Character) argument.static boolean
hasSingleStringArg(Closure c)
Does the Closure have a single String argument.
-
-
-
Method Detail
-
convertClosureToSource
public static java.lang.String convertClosureToSource(ReaderSource readerSource, ClosureExpression expression) throws java.lang.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:
java.lang.IllegalArgumentException
- when expression is nulljava.lang.Exception
- when closure can't be read from source
-
hasSingleCharacterArg
public static boolean hasSingleCharacterArg(Closure c)
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
public static boolean hasSingleStringArg(Closure c)
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
-
-