Код:
Код: Выделить всё
public class ClassFinderBasicRealisation implements ClassFinder {
private List> findClasses(String componentPath) {
List objects = objectInDirectory(componentPath);
List> getClasses() {
return allClassInProject;
}
private List objectInDirectory(String componentPath) {
try (var stream = ClassLoader.getSystemClassLoader()
.getResourceAsStream(componentPath.replaceAll("[.]", "/"));
var reader = new BufferedReader(new InputStreamReader(stream))) {
return reader.lines().collect(Collectors.toList());
} catch (NullPointerException e) {
throw new ComponentDirectoryIsEmpty(e);
} catch (IOException e) {
throw new LoadComponentException(e);
}
}
private List> recursiveTraversal(List objects, String componentPath) {
return objects.stream()
.filter(line -> !line.contains("."))
.map(directory -> findClasses(pathMerging(componentPath, directory)))
.flatMap(Collection::stream)
.collect(Collectors.toList());
}
}
Подробнее здесь: https://stackoverflow.com/questions/792 ... ceasstream
Мобильная версия