use of io.github.lukehutch.fastclasspathscanner.scanner.ScanResult in project typescript-generator by vojtechhabarta.
the class InputTest method testScanner.
@Test
public void testScanner() {
final ScanResult scanResult = new FastClasspathScanner().scan();
final List<String> allClassNames = scanResult.getNamesOfAllClasses();
final List<String> testClassNames = Input.filterClassNames(allClassNames, Arrays.asList("cz.habarta.typescript.generator.**Test"));
Assert.assertTrue("Typescript-generator must have at least 20 tests :-)", testClassNames.size() > 20);
}
use of io.github.lukehutch.fastclasspathscanner.scanner.ScanResult in project geode by apache.
the class DeployedJar method findFunctionsInThisJar.
private List<String> findFunctionsInThisJar() throws IOException {
URLClassLoader urlClassLoader = new URLClassLoader(new URL[] { this.getFile().getCanonicalFile().toURL() });
FastClasspathScanner fastClasspathScanner = new FastClasspathScanner().removeTemporaryFilesAfterScan(true).overrideClassLoaders(urlClassLoader);
ScanResult scanResult = fastClasspathScanner.scan();
return scanResult.getNamesOfClassesImplementing(Function.class);
}
use of io.github.lukehutch.fastclasspathscanner.scanner.ScanResult in project junit5 by junit-team.
the class ApiReportGenerator method generateReport.
// -------------------------------------------------------------------------
ApiReport generateReport(String... packages) {
final Logger logger = LoggerFactory.getLogger(ApiReportGenerator.class);
final String EOL = System.lineSeparator();
// Scan packages
ScanResult scanResult = new FastClasspathScanner(packages).scan();
// Collect names
List<String> names = new ArrayList<>();
names.addAll(scanResult.getNamesOfClassesWithAnnotation(API.class));
names.addAll(scanResult.getNamesOfAnnotationsWithMetaAnnotation(API.class));
logger.debug(() -> {
StringBuilder builder = new StringBuilder(names.size() + " @API declarations (including meta) found in class-path:");
builder.append(EOL);
scanResult.getUniqueClasspathElements().forEach(e -> builder.append(e).append(EOL));
return builder.toString();
});
// Collect types
List<Class<?>> types = scanResult.classNamesToClassRefs(names);
// only retain directly annotated types
types.removeIf(c -> !c.isAnnotationPresent(API.class));
types.sort(Comparator.comparing(type -> type.getName()));
logger.debug(() -> {
StringBuilder builder = new StringBuilder("Listing of all " + types.size() + " annotated types:");
builder.append(EOL);
types.forEach(e -> builder.append(e).append(EOL));
return builder.toString();
});
// Build map
Map<Status, List<Class<?>>> declarationsMap = new EnumMap<>(Status.class);
for (Status status : Status.values()) {
declarationsMap.put(status, new ArrayList<>());
}
types.forEach(type -> declarationsMap.get(type.getAnnotation(API.class).status()).add(type));
// Create report
return new ApiReport(types, declarationsMap);
}
Aggregations