@Override protected boolean addClassImport(CtTypeReference<?> ref) { boolean shouldTypeBeImported = this.shouldTypeBeImported(ref); if (shouldTypeBeImported) { return super.addClassImport(ref); } else { return false; } }
@Override protected boolean addFieldImport(CtFieldReference ref) { if (ref.getDeclaringType() != null) { if (isImportedInClassImports(ref.getDeclaringType())) { return false; } } boolean shouldTypeBeImported = this.shouldTypeBeImported(ref); if (shouldTypeBeImported) { if (this.fieldImports.containsKey(ref.getSimpleName())) { return isImportedInFieldImports(ref); } fieldImports.put(ref.getSimpleName(), ref); return true; } else { return false; } }
@Override protected boolean addMethodImport(CtExecutableReference ref) { if (ref.getDeclaringType() != null) { if (isImportedInClassImports(ref.getDeclaringType())) { return false; } } boolean shouldTypeBeImported = this.shouldTypeBeImported(ref); if (shouldTypeBeImported) { if (this.methodImports.containsKey(ref.getSimpleName())) { return isImportedInMethodImports(ref); } methodImports.put(ref.getSimpleName(), ref); if (ref.getDeclaringType() != null) { if (ref.getDeclaringType().getPackage() != null) { if (ref.getDeclaringType().getPackage().equals(this.targetType.getPackage())) { addClassImport(ref.getDeclaringType()); } } } return true; } else { return false; } }