public class ImportCustomizer
extends CompilationCustomizer
This compilation customizer allows adding various types of imports to the compilation unit. Supports adding:
| Constructor and description |
|---|
ImportCustomizer()Creates an import customizer that runs during conversion. |
| Type Params | Return Type | Name and description |
|---|---|---|
|
public ImportCustomizer |
addImport(String alias, String className)Adds a regular import with an explicit alias. |
|
public ImportCustomizer |
addImports(String classNames)Adds one or more regular imports. |
|
public ImportCustomizer |
addModuleImports(String moduleNames)Adds module imports. |
|
public ImportCustomizer |
addStarImports(String packageNames)Adds one or more star imports. |
|
public ImportCustomizer |
addStaticImport(String className, String fieldName)Adds a static import for a single member without an alias. |
|
public ImportCustomizer |
addStaticImport(String alias, String className, String fieldName)Adds a static import for a single member with an alias. |
|
public ImportCustomizer |
addStaticStars(String classNames)Adds one or more static star imports. |
|
public void |
call(SourceUnit source, GeneratorContext context, ClassNode classNode)Applies the configured imports to the module represented by the current class. |
| Methods inherited from class | Name |
|---|---|
class CompilationCustomizer |
getPhase |
Creates an import customizer that runs during conversion.
Adds a regular import with an explicit alias.
alias - the import aliasclassName - the fully qualified class name to importAdds one or more regular imports.
classNames - the fully qualified class names to import Adds module imports. Each module name (e.g. "java.sql") is expanded
at compilation time into star imports for all packages exported by that module,
including packages from transitively required modules (per JEP 476).
moduleNames - the JPMS module names to importAdds one or more star imports.
packageNames - the package names to import fromAdds a static import for a single member without an alias.
className - the fully qualified declaring class namefieldName - the static member nameAdds a static import for a single member with an alias.
alias - the alias to exposeclassName - the fully qualified declaring class namefieldName - the static member nameAdds one or more static star imports.
classNames - the fully qualified class names to import members fromApplies the configured imports to the module represented by the current class.
source - the source unit being customizedcontext - the current generator contextclassNode - the class node being customizedCopyright © 2003-2026 The Apache Software Foundation. All rights reserved.