addImport

open fun addImport(importDeclaration: ImportDeclaration): CompilationUnit(source)

adds an import if not implicitly imported by java (i.e. java.lang) or added before. Asterisk imports overrule the other imports within the same package.

Return

this

Parameters

importDeclaration

Add an import to the list of ImportDeclaration of this compilation unit shorthand for addImport with name,false,false,false

Return

this, the CompilationUnit

Parameters

name

the import name


open fun addImport(clazz: Class<out Any>): CompilationUnit(source)

Add an import to the list of ImportDeclaration of this compilation unit shorthand for addImport with clazz.getName()

Return

this, the CompilationUnit

Parameters

clazz

the class to import

Throws

if clazz is an anonymous or local class


open fun addImport(name: String, isStatic: Boolean, isAsterisk: Boolean): CompilationUnit(source)

Add a non-module import to the list of ImportDeclaration of this compilation unitThis method check if no import with the same name is already in the list

Return

this, the CompilationUnit

Parameters

name

the import name

isStatic

is it an "import static"

isAsterisk

does the import end with ".*"


open fun addImport(name: String, isStatic: Boolean, isAsterisk: Boolean, isModule: Boolean): CompilationUnit(source)

Add an import to the list of ImportDeclaration of this compilation unitThis method check if no import with the same name is already in the list

Return

this, the CompilationUnit

Parameters

name

the import name

isStatic

is it an "import static"

isAsterisk

does the import end with ".*"

isModule

is it an "import module"