class DATypeImportComputer {

  public static Collection<DAImport> computeImports(DAType daType) {
    List<DAImport> qualifiedName = hasQualifiedNameToImport(daType)
        ? Collections.<DAImport>emptyList() : Collections.singletonList(DAImportImpl.from(daType.getQualifiedName()));

    Set<DAImport> res = new HashSet<DAImport>();
    addAll(res, qualifiedName);
    List<Collection<DAImport>> argsImportLists = from(daType.getTypeArgs()).transform(COMPUTE_IMPORTS).toList();
    for (Collection<DAImport> importList : argsImportLists) {
      addAll(res, importList);
    }
    addAll(res,
        daType.getSuperBound() == null ? Collections.<DAImport>emptyList() : computeImports(daType.getSuperBound())
    );
    addAll(res, daType.getExtendsBound() == null ? Collections.<DAImport>emptyList() : computeImports(daType.getExtendsBound()));
    return res;
  }

}

class DATypeImportComputerTest {

  @Test
  public void getImports_does_not_import_classes_from_java_lang() throws Exception {

    DAType daType = DATypeFactory.from(String.class);
    Assertions.assertThat(DATypeImportComputer.computeImports(daType)).isEmpty();

    daType = daType("test.Toto", ImmutableList.of(DATypeFactory.from(Integer.class)));
    Assertions.assertThat(DATypeImportComputer.computeImports(daType)).extracting("qualifiedName.name").containsOnly("test.Toto");
  }

}