A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/burningwave/core/wiki/Finding-all-classes-for-module-name-(Java-9-and-later) below:

Finding all classes for module name (Java 9 and later) · burningwave/core Wiki · GitHub

Here the solution:

import java.util.Collection;

import org.burningwave.core.assembler.ComponentContainer;
import org.burningwave.core.assembler.ComponentSupplier;
import org.burningwave.core.classes.ClassCriteria;
import org.burningwave.core.classes.ClassHunter;
import org.burningwave.core.classes.ClassHunter.SearchResult;
import org.burningwave.core.classes.SearchConfig;
import org.burningwave.core.io.PathHelper;

public class Finder {

    public Collection<Class<?>> find() {
        ComponentSupplier componentSupplier = ComponentContainer.getInstance();
        PathHelper pathHelper = componentSupplier.getPathHelper();
        ClassHunter classHunter = componentSupplier.getClassHunter();

        try (ClassHunter.SearchResult searchResult = classHunter.findBy(
                SearchConfig.forPaths(
                	pathHelper.getAllMainClassPaths()
                ).by(
                    ClassCriteria.create().allThoseThatMatch((currentScannedClass) ->
                        currentScannedClass.getModule().getName() != null && 
                        currentScannedClass.getModule().getName().equals("jdk.xml.dom")
                    )
                )
            )
        ) {
            return searchResult.getClasses();
        }
    }
}

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4