Jacobvu84 / serenity-pageobject-junit-webdriver

4 stars 1 forks source link

Find Java classes implementing an interface #73

Open Jacobvu84 opened 4 years ago

Jacobvu84 commented 4 years ago

import java.util.HashSet;
import java.util.Set;

import net.sf.extcos.ComponentQuery;
import net.sf.extcos.ComponentScanner;

public class FindAllClass
{
    public static void main (String[] args) throws Throwable
    {
        Set<Class<? extends MyInterface>> classes = new HashSet<Class<? extends MyInterface>>();

        ComponentScanner scanner = new ComponentScanner();
        scanner.getClasses(new ComponentQuery() {
            @Override
            protected void query() {
                select().
                from("com.betterengage.features").
                andStore(thoseImplementing(MyInterface.class).into(classes)).
                returning(none());
            }
        });

        classes.forEach(action->System.out.println(action));
    }
}
Jacobvu84 commented 4 years ago
<!-- https://mvnrepository.com/artifact/net.sf.extcos/extcos -->
<dependency>
    <groupId>net.sf.extcos</groupId>
    <artifactId>extcos</artifactId>
    <version>0.4b</version>
</dependency>