Package: org.codehaus.groovy.control.customizers

## [Java] Class CompilationCustomizer

- org.codehaus.groovy.control.customizers.CompilationCustomizer

- All Implemented Interfaces and Traits:
    CompilationUnitIPrimaryClassNodeOperation

      public abstract class CompilationCustomizer
      extends Object
      implements CompilationUnitIPrimaryClassNodeOperation

  Users wanting to customize the configuration process such as adding imports, restricting the language features or apply AST transformations by default should implement this class, then call the CompilerConfiguration.addCompilationCustomizers method.

  A customizer is registered for a particular compilation and is invoked for every primary class node of it. Two consequences are easy to overlook:

  - The `SourceUnit` passed to CompilationUnit.IPrimaryClassNodeOperation#call may be `null`, for class nodes supplied directly via CompilationUnit#addClassNode(org.codehaus.groovy.ast.ClassNode) rather than parsed from source. Guard accordingly; an unguarded dereference surfaces as a GroovyBugError rather than as your own exception.
  - A customizer should not assume the class nodes it sees belong to the compilation it was registered for. A configuration may be copied for a nested compilation, which carries its customizers along unless CompilerConfiguration.CompilerConfiguration is used to omit them.
  Since:
    1.8.0

- - ### Constructor Summary

    Constructors
    Constructor and description
    `CompilationCustomizer(CompilePhase phase)` Creates a customizer bound to the supplied compile phase.

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public CompilePhase` | `getPhase()` Returns the compile phase in which this customizer runs.

  - ### Inherited Methods Summary

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

- - ### Constructor Detail

    - #### public CompilationCustomizer(CompilePhase phase)

      Creates a customizer bound to the supplied compile phase.

      Parameters:
        `phase` - the phase in which this customizer should run

  - ### Method Detail

    - #### public CompilePhase getPhase()

      Returns the compile phase in which this customizer runs.

      Returns:
        the configured compile phase