Groovy Documentation

## org.codehaus.groovy.control.customizers
[Java] Class ImportCustomizer

    java.lang.Object
      CompilationUnit.PrimaryClassNodeOperation
          org.codehaus.groovy.control.customizers.CompilationCustomizer
              org.codehaus.groovy.control.customizers.ImportCustomizer

    public class ImportCustomizer
    extends CompilationCustomizer

This compilation customizer allows addiing various types of imports to the compilation unit. Supports adding :

- standard imports thanks to addImport(String), addImport(String, String) or addImports(String...)
- star imports thanks to addStarImport(String) or addStarImports(String...)
- static imports thanks to addStaticImport(String, String) or addStaticImport(String, String, String)
- static star imports thanks to addStaticStar(String) or addStaticStars(String...)

Authors:
  Cedric Champeau

Since:
  1.8.0

Constructor Summary
`ImportCustomizer()`

Method Summary
`ImportCustomizer` | `addImport(java.lang.String alias, java.lang.String className)`
`ImportCustomizer` | `addImports(java.lang.String... imports)`
`ImportCustomizer` | `addStarImports(java.lang.String... packageNames)`
`ImportCustomizer` | `addStaticImport(java.lang.String className, java.lang.String fieldName)`
`ImportCustomizer` | `addStaticImport(java.lang.String alias, java.lang.String className, java.lang.String fieldName)`
`ImportCustomizer` | `addStaticStars(java.lang.String... classNames)`
`void` | `call(SourceUnit source, GeneratorContext context, ClassNode classNode)`

Methods inherited from class CompilationCustomizer
getPhase

Constructor Detail

### ImportCustomizer

    public ImportCustomizer()

Method Detail

### addImport

    public ImportCustomizer addImport(java.lang.String alias, java.lang.String className)

### addImports

    public ImportCustomizer addImports(java.lang.String... imports)

### addStarImports

    public ImportCustomizer addStarImports(java.lang.String... packageNames)

### addStaticImport

    public ImportCustomizer addStaticImport(java.lang.String className, java.lang.String fieldName)

### addStaticImport

    public ImportCustomizer addStaticImport(java.lang.String alias, java.lang.String className, java.lang.String fieldName)

### addStaticStars

    public ImportCustomizer addStaticStars(java.lang.String... classNames)

### call

    @Override
    public void call(SourceUnit source, GeneratorContext context, ClassNode classNode)

Groovy Documentation