.stream() .filter(once) .map(ClassInfo::getName) .stream() .filter(once) .map(ClassInfo::getName) .filter(A) .forEach(a -> result.getClassesWithAnnotation(a.getName()) .stream() .filter(once) .map(ClassInfo::getName) .filter(type -> type != Jooby.Module.class && type != Module.class && type != Service.class) .forEach(i -> result.getClassesImplementing(i.getName()) .stream() .filter(inPackage) .filter(once) .filter(S) .forEach(k -> result.getSubclasses(k.getName()) .stream() .filter(inPackage) .filter(once) .stream() .filter(inPackage) .filter(once)
/** * Searches for the implementations/subtypes of the given class. Only the matching classes are loaded. * * @param superType The type the implementations/subtypes of which are to be searched for * @param packages The packages to limit the search to * * @return A collection of classes discovered that implementation/extend {@code superType} */ public List<Class<?>> findImplementations(Class superType, Predicate<ClassInfo> filter, String... packages) { String[] scanPackages = Utils.emptyIfNull(packages); String cacheKey = Arrays.stream(scanPackages).sorted().collect(Collectors.joining()); ScanResult scanResults = cache.computeIfAbsent(cacheKey, k -> new ClassGraph() .whitelistPackages(packages) .enableAllInfo() .initializeLoadedClasses() .scan()); try { return scanResults.getAllClasses().stream() .filter(impl -> superType.isInterface() ? impl.implementsInterface(superType.getName()) : impl.extendsSuperclass(superType.getName())) .filter(filter == null ? info -> true : filter) .flatMap(info -> loadClass(info, superType)) .collect(Collectors.toList()); } catch (Exception e) { log.error("Failed to auto discover the subtypes of " + superType.getName() + ". Error encountered while scanning the classpath/modulepath.", e); return Collections.emptyList(); } }
List<String> annotationClassNames = annotationHandlers.stream() .map(classInfo -> classInfo.getDeclaredMethodInfo("handles")) .flatMap(Collection::stream)