@Nonnull
    @SuppressFBWarnings(value = "RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE", justification =
            "False positive on try-with-resources as of JDK11")
    public static Resources resourcesOf(String... packages) {
        String[] paths = stream(packages).map(ReflectionUtils::toPath).toArray(String[]::new);
        ClassGraph classGraph = new ClassGraph()
                .whitelistPackages(packages)
                .whitelistPaths(paths)
                .ignoreClassVisibility();
        try (ScanResult scanResult = classGraph.scan()) {
            Collection<ClassResource> classes =
                    scanResult.getAllClasses().stream().map(ClassResource::new).collect(toList());
            Collection<URL> nonClasses = scanResult.getAllResources().nonClassFilesOnly().getURLs();
            return new Resources(classes, nonClasses);
        }
    }
@Test
    public void when_resourcesOf_then_returnsAllResources() throws ClassNotFoundException {
        // When
        Resources resources = ReflectionUtils.resourcesOf(OuterClass.class.getPackage().getName());

        // Then
        Collection<ClassResource> classes = resources.classes().collect(toList());
        assertThat(classes).hasSizeGreaterThan(5);
        assertThat(classes).contains(classResource(OuterClass.class));
        assertThat(classes).contains(classResource(OuterClass.NestedClass.class));
        assertThat(classes).contains(classResource(OuterClass.NestedClass.DeeplyNestedClass.class));
        assertThat(classes).contains(classResource(Class.forName(OuterClass.class.getName() + "$1")));
        assertThat(classes).contains(
                classResource(Class.forName(OuterClass.NestedClass.DeeplyNestedClass.class.getName() + "$1"))
        );

        List<URL> nonClasses = resources.nonClasses().collect(toList());
        assertThat(nonClasses).hasSize(5);
        assertThat(nonClasses).map(v -> substringAfterLast(v.toString(), "/"))
                              .contains("file.json")
                              .contains("file_list.json")
                              .contains("file_pretty_printed.json")
                              .contains("file_list_pretty_printed.json")
                              .contains("package.properties");
    }