org.codehaus.groovy.control.customizers.builder

## Class SourceAwareCustomizerFactory

- java.lang.Object
- - groovy.util.AbstractFactory
  - - org.codehaus.groovy.control.customizers.builder.SourceAwareCustomizerFactory

- All Implemented Interfaces:
    Factory, PostCompletionFactory

      public class SourceAwareCustomizerFactory
      extends AbstractFactory
      implements PostCompletionFactory

  Factory for use with `CompilerCustomizationBuilder`. Allows the construction of `source aware customizers`. Syntax:

           // apply CompileStatic AST annotation on .sgroovy files
           builder.source(extension: 'sgroovy') {
               ast(CompileStatic)
           }

           // apply CompileStatic AST annotation on .sgroovy or .sg files
           builder.source(extensions: ['sgroovy','sg']) {
               ast(CompileStatic)
           }

           // apply CompileStatic AST annotation on .sgroovy or .sg files
           builder.source(extensionValidator: { it.name in ['sgroovy','sg']}) {
               ast(CompileStatic)
           }

           // apply CompileStatic AST annotation on files whose name is 'foo'
           builder.source(basename: 'foo') {
               ast(CompileStatic)
           }

           // apply CompileStatic AST annotation on files whose name is 'foo' or 'bar'
           builder.source(basenames: ['foo', 'bar']) {
               ast(CompileStatic)
           }

           // apply CompileStatic AST annotation on files whose name is 'foo' or 'bar'
           builder.source(basenameValidator: { it in ['foo', 'bar'] }) {
               ast(CompileStatic)
           }

           // apply CompileStatic AST annotation on files that do not contain a class named 'Baz'
           builder.source(unitValidator: { unit -> !unit.AST.classes.any { it.name == 'Baz' } }) {
               ast(CompileStatic)
           }

           // apply CompileStatic AST annotation on class nodes that end with 'CS'
           builder.source(classValidator: { cn -> cn.name.endsWith('CS') }) {
               ast(CompileStatic)
           }

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `SourceAwareCustomizerFactory.SourceOptions`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SourceAwareCustomizerFactory()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.lang.Object` | `newInstance(FactoryBuilderSupport builder, java.lang.Object name, java.lang.Object value, java.util.Map attributes)`
    `java.lang.Object` | `postCompleteNode(FactoryBuilderSupport factory, java.lang.Object parent, java.lang.Object node)`
    `void` | `setChild(FactoryBuilderSupport builder, java.lang.Object parent, java.lang.Object child)`

    - ### Methods inherited from class groovy.util.AbstractFactory

      `isHandlesNodeChildren, isLeaf, onFactoryRegistration, onHandleNodeAttributes, onNodeChildren, onNodeCompleted, setParent`

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

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

- - ### Constructor Detail

    - #### SourceAwareCustomizerFactory

          public SourceAwareCustomizerFactory()

  - ### Method Detail

    - #### newInstance

          public java.lang.Object newInstance(FactoryBuilderSupport builder,
                                              java.lang.Object name,
                                              java.lang.Object value,
                                              java.util.Map attributes)
                                       throws java.lang.InstantiationException,
                                              java.lang.IllegalAccessException

      Specified by:
        `newInstance` in interface `Factory`
      Parameters:
        `builder` - the FactoryBuilder
        `name` - the name of the node being built
        `value` - the 'value' argument in the build node
        `attributes` - the attributes of the build arg
      Returns:
        the object created for the builder
      Throws:
        `java.lang.InstantiationException` - if attempting to instantiate an interface or abstract class
        `java.lang.IllegalAccessException` - if the instance can't be created due to a security violation

    - #### setChild

          public void setChild(FactoryBuilderSupport builder,
                               java.lang.Object parent,
                               java.lang.Object child)

      Specified by:
        `setChild` in interface `Factory`
      Overrides:
        `setChild` in class `AbstractFactory`

    - #### postCompleteNode

          public java.lang.Object postCompleteNode(FactoryBuilderSupport factory,
                                                   java.lang.Object parent,
                                                   java.lang.Object node)

      Specified by:
        `postCompleteNode` in interface `PostCompletionFactory`