Package: org.codehaus.groovy.macro.runtime

## [Java] Enum MacroBuilder

- org.codehaus.groovy.macro.runtime.MacroBuilder

-     public enum MacroBuilder

  Runtime support for

      macro { }

  method.
  Since:
    2.5.0

- - ### Enum Constants Summary

    Enum constants classes
    Enum constant | Description
    --- | ---
    `INSTANCE` | Shared macro builder instance.

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public static ASTNode` | `getMacroValue(BlockStatement closureBlock, boolean asIs)` Extracts the value represented by a parsed macro closure.
    `<T>` | `public T` | `macro(String source, List<Closure<Expression>> context, Class<T> resultClass)` Builds a macro value from source text using the conversion phase.
    `<T>` | `public T` | `macro(boolean asIs, String source, List<Closure<Expression>> context, Class<T> resultClass)` Builds a macro value from source text using the conversion phase.
    `<T>` | `public T` | `macro(CompilePhase compilePhase, String source, List<Closure<Expression>> context, Class<T> resultClass)` Builds a macro value from source text at the supplied compile phase.
    `<T>` | `public T` | `macro(CompilePhase compilePhase, boolean asIs, String source, List<Closure<Expression>> context, Class<T> resultClass)` Builds a macro value from source text.

  - ### Inherited Methods Summary

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

- - ### Enum Constant Detail

    - #### MacroBuilder INSTANCE

      Shared macro builder instance.

  - ### Method Detail

    - #### public static ASTNode getMacroValue(BlockStatement closureBlock, boolean asIs)

      Extracts the value represented by a parsed macro closure.

      Parameters:
        `closureBlock` - the parsed closure block
        `asIs` - whether to keep a single-statement closure as a block
      Returns:
        the resulting AST node

    - #### <T> public T macro(String source, List<Closure<Expression>> context, Class<T> resultClass)

      Builds a macro value from source text using the conversion phase.

      Parameters:
        `source` - the source to parse
        `context` - the substitution closures used for `$v` placeholders
        `resultClass` - the expected result type
      Type Parameters:
        `T` - the expected result type
      Returns:
        the built macro value

    - #### <T> public T macro(boolean asIs, String source, List<Closure<Expression>> context, Class<T> resultClass)

      Builds a macro value from source text using the conversion phase.

      Parameters:
        `asIs` - whether to keep a single-statement closure as a block
        `source` - the source to parse
        `context` - the substitution closures used for `$v` placeholders
        `resultClass` - the expected result type
      Type Parameters:
        `T` - the expected result type
      Returns:
        the built macro value

    - #### <T> public T macro(CompilePhase compilePhase, String source, List<Closure<Expression>> context, Class<T> resultClass)

      Builds a macro value from source text at the supplied compile phase.

      Parameters:
        `compilePhase` - the phase to use when parsing the source
        `source` - the source to parse
        `context` - the substitution closures used for `$v` placeholders
        `resultClass` - the expected result type
      Type Parameters:
        `T` - the expected result type
      Returns:
        the built macro value

    - #### <T> public T macro(CompilePhase compilePhase, boolean asIs, String source, List<Closure<Expression>> context, Class<T> resultClass)

      Builds a macro value from source text.

      Parameters:
        `compilePhase` - the phase to use when parsing the source, or `null` for conversion
        `asIs` - whether to keep a single-statement closure as a block
        `source` - the source to parse
        `context` - the substitution closures used for `$v` placeholders
        `resultClass` - the expected result type
      Type Parameters:
        `T` - the expected result type
      Returns:
        the built macro value