}
protected def imports() '''
- «IF !importMap.empty»
- «FOR entry : importMap.entrySet»
- «IF !hasSamePackage(entry.value)»
- import «entry.value».«entry.key»;
- «ENDIF»
- «ENDFOR»
- «ENDIF»
-
+ «FOR entry : importMap.entrySet»
+ «IF !hasSamePackage(entry.value) && !isLocalInnerClass(entry.value)»
+ import «entry.value».«entry.key»;
+ «ENDIF»
+ «ENDFOR»
'''
/**
* Checks if packages of generated type and imported type is the same
*
- * @param importedTypePackageNam
- * the package name of imported type
+ * @param importedTypePackageName the package name of imported type
* @return true if the packages are the same false otherwise
*/
final private def boolean hasSamePackage(String importedTypePackageName) {
return type.packageName.equals(importedTypePackageName);
}
+ def isLocalInnerClass(String importedTypePackageName) {
+ return type.fullyQualifiedName.equals(importedTypePackageName);
+ }
+
protected abstract def CharSequence body();
// Helper patterns
/**
* Constant with the name of the BuilderFor interface
*/
- val static BUILDERFOR = Builder.simpleName;
+ val static BUILDERFOR = Builder.simpleName;
/**
* Constant with suffix for the classes which are generated from the builder classes.
}
}
+ override isLocalInnerClass(String importedTypePackageName) {
+ // Builders do not have inner types
+ return false;
+ }
+
/**
* Template method which generates JAVA class body for builder class and for IMPL class.
*
*/
override body() '''
«wrapToDocumentation(formatDataForJavaDoc(type))»
- public class «type.name»«BUILDER» implements «BUILDERFOR» <«type.importedName»> {
+ public class «type.name»«BUILDER» implements «BUILDERFOR»<«type.importedName»> {
«generateFields(false)»