當前位置: 首頁>>代碼示例>>Java>>正文


Java FastClasspathScanner.matchClassesImplementing方法代碼示例

本文整理匯總了Java中io.github.lukehutch.fastclasspathscanner.FastClasspathScanner.matchClassesImplementing方法的典型用法代碼示例。如果您正苦於以下問題:Java FastClasspathScanner.matchClassesImplementing方法的具體用法?Java FastClasspathScanner.matchClassesImplementing怎麽用?Java FastClasspathScanner.matchClassesImplementing使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在io.github.lukehutch.fastclasspathscanner.FastClasspathScanner的用法示例。


在下文中一共展示了FastClasspathScanner.matchClassesImplementing方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getInstance

import io.github.lukehutch.fastclasspathscanner.FastClasspathScanner; //導入方法依賴的package包/類
public static OrchidFlags getInstance() {
    if (instance == null) {
        List<OrchidFlag> orchidFlags = new ArrayList<>();

        FastClasspathScanner scanner = new FastClasspathScanner();
        scanner.matchClassesImplementing(OrchidFlag.class, (matchingClass) -> {
            try {
                OrchidFlag option = matchingClass.newInstance();
                if (option != null) {
                    orchidFlags.add(option);
                }
            }
            catch (Exception e) {
                e.printStackTrace();
            }
        });
        scanner.scan();
        instance = new OrchidFlags(orchidFlags);
    }
    return instance;
}
 
開發者ID:JavaEden,項目名稱:Orchid,代碼行數:22,代碼來源:OrchidFlags.java

示例2: getClassesImplementing

import io.github.lukehutch.fastclasspathscanner.FastClasspathScanner; //導入方法依賴的package包/類
@Override
@SuppressWarnings({ "unchecked", "rawtypes" }) // Raw types usage due to awkward generics API.
public Iterable<Class<?>> getClassesImplementing(final Class<?> root, final Class<?>... interfaces) {
    final Set<Class<?>> classes = new HashSet<>();
    final FastClasspathScanner scanner = new FastClasspathScanner(root.getPackage().getName());
    for (final Class<?> implemented : interfaces) {
        scanner.matchClassesImplementing(implemented, new InterfaceMatchProcessor() {
            @Override
            public void processMatch(final Class implementingClass) {
                if (!Modifier.isAbstract(implementingClass.getModifiers()) && !implementingClass.isInterface()) {
                    classes.add(implementingClass);
                }
            }
        });
    }
    scanner.scan();
    return classes;
}
 
開發者ID:czyzby,項目名稱:uedi,代碼行數:19,代碼來源:DefaultClassScanner.java

示例3: configure

import io.github.lukehutch.fastclasspathscanner.FastClasspathScanner; //導入方法依賴的package包/類
@Override
protected void configure() {
    final StringBuilder moduleLog = new StringBuilder();
    moduleLog.append("Auto-loading modules: ");
    moduleLog.append("\n--------------------");

    FastClasspathScanner scanner = new FastClasspathScanner();
    scanner.matchClassesImplementing(Module.class, (matchingClass) -> {
        if (isInstantiable(matchingClass)) {
            try {
                Module provider = matchingClass.newInstance();
                if (provider != null) {
                    install(provider);
                    if (!provider.getClass().getName().startsWith("com.eden.orchid.OrchidModule")) {
                        moduleLog.append("\n * " + provider.getClass().getName());
                    }
                }
            }
            catch (Exception e) {
                e.printStackTrace();
            }
        }
    });
    scanner.scan();

    moduleLog.append("\n--------------------");
    Clog.i(moduleLog.toString());
}
 
開發者ID:JavaEden,項目名稱:Orchid,代碼行數:29,代碼來源:ClasspathModuleInstaller.java


注:本文中的io.github.lukehutch.fastclasspathscanner.FastClasspathScanner.matchClassesImplementing方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。