Package org.faktorips.codegen
Class ImportDeclaration
java.lang.Object
org.faktorips.codegen.ImportDeclaration
An ImportDeclaration is an ordered set of import statements.
When adding new import statements it is checked that no unnecessary statements are added, for
example if you add java.util.ArrayList and then java.util.* only the
latter statement is kept. Also import statements for classes residing in java.lang
and for primitive types are ignored.
- Author:
- Jan Ortmann
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new import declaration.Copy constructor.ImportDeclaration(ImportDeclaration decl, String packageName) Constructs a new import declaration that contains all import statements from the given declaration that are not covered by the package. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds the class to the import list.voidAdds the import specification to the list of imports.voidAdds the import specifications to the list of imports.voidadd(ImportDeclaration decl) Adds all imports in the given import declaration to this declaration.booleanintReturns the number of imports.getUncoveredImports(ImportDeclaration importsToTest) Returns those imports in theimportsToTestdeclaration that are not covered this one.inthashCode()booleanReturns true if the class is covered by the import declaration.booleanReturns true if the import specification is covered by this import declaration.static final booleanisPackageImport(String importSpec) Returns true if this is a package import, e.g.iterator()Returns an Iterator over the import statements as Strings.toString()Returns the import statements as a string.
-
Constructor Details
-
ImportDeclaration
public ImportDeclaration()Creates a new import declaration. -
ImportDeclaration
Copy constructor. -
ImportDeclaration
Constructs a new import declaration that contains all import statements from the given declaration that are not covered by the package.
-
-
Method Details
-
isPackageImport
Returns true if this is a package import, e.g.java.util.*Returns false if importSpec is null. -
add
Adds the class to the import list. -
add
Adds all imports in the given import declaration to this declaration. Does nothing if the given import decl is null. -
add
Adds the import specifications to the list of imports. Does nothing if the given importSpecs is null. -
add
Adds the import specification to the list of imports. Does nothing if the given importSpecs is null. -
isCovered
Returns true if the class is covered by the import declaration. That is, if either an import for that class exists or the package the class resides in is imported.- Throws:
NullPointerException- if clazz is null.
-
isCovered
Returns true if the import specification is covered by this import declaration.- Throws:
NullPointerException- if importSpec is null.
-
iterator
Returns an Iterator over the import statements as Strings. -
getImports
-
getNoOfImports
public int getNoOfImports()Returns the number of imports. -
getUncoveredImports
Returns those imports in theimportsToTestdeclaration that are not covered this one. Returns an empty import declaration if either all imports are covered or importsToTest isnull. -
hashCode
public int hashCode() -
equals
-
toString
Returns the import statements as a string. The import statements are separated by a line separator. Each line has a trailing "import " and ends with a semicolon (;).
-