0
votes

I am trying to get a list/reference to all the classes in a particular package using the Burningwave Maven package. Here's my code:

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

    CacheableSearchConfig searchConfig = SearchConfig.forPaths(
        pathHelper.getAllMainClassPaths(),
        pathHelper.getPaths(PathHelper.Configuration.Key.MAIN_CLASS_REPOSITORIES)
    ).by(
        ClassCriteria.create().allThoseThatMatch((cls) -> {
            return cls.getPackage().getName().matches(".*springframework.*");
        }));
    try (SearchResult searchResult = classHunter.loadInCache(searchConfig).find()) {
        return searchResult.getClasses();
    }
}

IntelliJ IDEA says that I need another argument in the getClasses() method.

When I try to run it, I get the following error.

Error:(105, 32) java: method getClasses in class org.burningwave.core.classes.SearchResult cannot be applied to given types;
required: org.burningwave.core.classes.CriteriaWithClassElementsSupplyingSupport
found: no arguments
reason: actual and formal argument lists differ in length

1

1 Answers

1
votes

Replace the SearchResult type in your try/catch block with org.burningwave.core.classes.ClassHunter.SearchResult, e.g:

    try (org.burningwave.core.classes.ClassHunter.SearchResult searchResult = classHunter.loadInCache(searchConfig).find()) {
        return searchResult.getClasses();
    }}