private List<String> packImports() { return mapSimpleNames .entrySet() .stream() .filter( ent -> // exclude the current class or one of the nested ones // empty, java.lang and the current packages !setNotImportedNames.contains(ent.getKey()) && !ent.getValue().isEmpty() && !JAVA_LANG_PACKAGE.equals(ent.getValue()) && !ent.getValue().equals(currentPackagePoint)) .sorted( Map.Entry.<String, String>comparingByValue().thenComparing(Map.Entry.comparingByKey())) .map(ent -> ent.getValue() + "." + ent.getKey()) .collect(Collectors.toList()); }