ClosureUtils (Groovy 5.0.7)

Package: org.codehaus.groovy.ast.tools

## [Java] Class ClosureUtils

- org.codehaus.groovy.ast.tools.ClosureUtils

-     public class ClosureUtils
      extends Object

  Handy methods when working with Closure AST data structures.

- - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public static String` | `convertClosureToSource(ReaderSource readerSource, ClosureExpression expression)` Converts a ClosureExpression into the String source.
    `` | `public static Parameter[]` | `getParametersSafe(ClosureExpression ce)` Returns: the parameters for the ClosureExpression
    `` | `public static String` | `getResolveStrategyName(int resolveStrategy)` Returns the constant name associated with the given resolve strategy.
    `` | `public static boolean` | `hasImplicitParameter(ClosureExpression ce)` Returns: true if the ClosureExpression has an implicit 'it' parameter
    `` | `public static boolean` | `hasSingleCharacterArg(Closure c)` Does the Closure have a single char-like (char or Character) argument.
    `` | `public static boolean` | `hasSingleStringArg(Closure c)` Does the Closure have a single String argument.

  - ### Inherited Methods Summary

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

- - ### Method Detail

    - #### public static String convertClosureToSource(ReaderSource readerSource, ClosureExpression expression)

      Converts a ClosureExpression into the String source.

      throws:
        java.lang.IllegalArgumentException when expression is null
      throws:
        java.lang.Exception when closure can't be read from source
      Parameters:
        `readerSource` - a source
        `expression` - a closure. Can't be null
      Returns:
        the source the closure was created from

    - #### public static Parameter[] getParametersSafe(ClosureExpression ce)

      Returns:
        the parameters for the ClosureExpression

    - #### public static String getResolveStrategyName(int resolveStrategy)

      Returns the constant name associated with the given resolve strategy.

      See Also:
        Closure.DELEGATE_FIRST, et al.
      Since:
        3.0.5

    - #### public static boolean hasImplicitParameter(ClosureExpression ce)

      Returns:
        true if the ClosureExpression has an implicit 'it' parameter

    - #### 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

    - #### 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