Package org.codehaus.groovy.control.customizers

# Class DelegatingCustomizer

java.lang.Object
org.codehaus.groovy.control.customizers.CompilationCustomizer
org.codehaus.groovy.control.customizers.DelegatingCustomizer

All Implemented Interfaces:
  `CompilationUnitAware`, `CompilationUnit.IPrimaryClassNodeOperation`

Direct Known Subclasses:
  `SourceAwareCustomizer`

public abstract class DelegatingCustomizer extends CompilationCustomizer implements CompilationUnitAware
Base class for compilation customizers which delegate to another customizer. The phase this customizer runs at is retrieved from the phase of the delegate.

Since:
  2.1.0

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected final CompilationCustomizer`
  `delegate`
  Customizer that receives delegated callbacks.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `DelegatingCustomizer(CompilationCustomizer delegate)`
  Creates a delegating customizer backed by another customizer.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `call(SourceUnit source, GeneratorContext context, ClassNode classNode)`
  Delegates customization of the supplied class node.
  `void`
  `setCompilationUnit(CompilationUnit compilationUnit)`
  Forwards the compilation unit to the delegate when it supports the callback.

  ### Methods inherited from class org.codehaus.groovy.control.customizers.CompilationCustomizer

  `getPhase`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

  ### Methods inherited from interface org.codehaus.groovy.control.CompilationUnit.IPrimaryClassNodeOperation

  `doPhaseOperation, needSortedInput`

- ## Field Details

  - ### delegate

    protected final CompilationCustomizer delegate
    Customizer that receives delegated callbacks.

- ## Constructor Details

  - ### DelegatingCustomizer

    public DelegatingCustomizer(CompilationCustomizer delegate)
    Creates a delegating customizer backed by another customizer.
    Parameters:
      `delegate` - the customizer to delegate to

- ## Method Details

  - ### setCompilationUnit

    public void setCompilationUnit(CompilationUnit compilationUnit)
    Forwards the compilation unit to the delegate when it supports the callback.
    Specified by:
      `setCompilationUnit` in interface `CompilationUnitAware`
    Parameters:
      `compilationUnit` - the active compilation unit

  - ### call

    public void call(SourceUnit source, GeneratorContext context, ClassNode classNode) throws CompilationFailedException
    Delegates customization of the supplied class node.
    Specified by:
      `call` in interface `CompilationUnit.IPrimaryClassNodeOperation`
    Parameters:
      `source` - the source unit being compiled
      `context` - the current generator context
      `classNode` - the class node being customized
    Throws:
      `CompilationFailedException` - if the delegate fails