Package org.codehaus.groovy.control.customizers

## Class SourceAwareCustomizer

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

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

      public class SourceAwareCustomizer
      extends DelegatingCustomizer

  A base class for customizers which only have to be applied on specific source units. This is for example useful if you want a customizer to be applied only for files matching some extensions.

  For convenience, this class implements several methods that you may extend to customize the behaviour of this utility. For example, if you want to apply a customizer only for classes matching the '.foo' file extension, then you only have to override the `acceptExtension(String)` method:

      return "foo".equals(extension)

  Since:
    2.1.0

- - ### Field Summary

    - ### Fields inherited from class org.codehaus.groovy.control.customizers.DelegatingCustomizer

      `delegate`

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `SourceAwareCustomizer​(CompilationCustomizer delegate)` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `boolean` | `accept​(String fileName)` |
    `boolean` | `acceptBaseName​(String baseName)` |
    `boolean` | `acceptClass​(ClassNode cnode)` |
    `boolean` | `acceptExtension​(String extension)` |
    `boolean` | `acceptSource​(SourceUnit unit)` |
    `void` | `call​(SourceUnit source, GeneratorContext context, ClassNode classNode)` |
    `void` | `setBaseNameValidator​(Closure<Boolean> baseNameValidator)` |
    `void` | `setClassValidator​(Closure<Boolean> classValidator)` |
    `void` | `setExtensionValidator​(Closure<Boolean> extensionValidator)` |
    `void` | `setSourceUnitValidator​(Closure<Boolean> sourceUnitValidator)` |

    - ### Methods inherited from class org.codehaus.groovy.control.customizers.DelegatingCustomizer

      `setCompilationUnit`

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

- - ### Constructor Detail

    - #### SourceAwareCustomizer

          public SourceAwareCustomizer​(CompilationCustomizer delegate)

  - ### Method Detail

    - #### call

          public void call​(SourceUnit source,
                           GeneratorContext context,
                           ClassNode classNode)
                    throws CompilationFailedException

      Specified by:
        `call` in interface `CompilationUnit.IPrimaryClassNodeOperation`
      Overrides:
        `call` in class `DelegatingCustomizer`
      Throws:
        `CompilationFailedException`

    - #### setBaseNameValidator

          public void setBaseNameValidator​(Closure<Boolean> baseNameValidator)

    - #### setExtensionValidator

          public void setExtensionValidator​(Closure<Boolean> extensionValidator)

    - #### setSourceUnitValidator

          public void setSourceUnitValidator​(Closure<Boolean> sourceUnitValidator)

    - #### setClassValidator

          public void setClassValidator​(Closure<Boolean> classValidator)

    - #### accept

          public boolean accept​(String fileName)

    - #### acceptClass

          public boolean acceptClass​(ClassNode cnode)

    - #### acceptSource

          public boolean acceptSource​(SourceUnit unit)

    - #### acceptExtension

          public boolean acceptExtension​(String extension)

    - #### acceptBaseName

          public boolean acceptBaseName​(String baseName)