当前位置: 首页>>代码示例>>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;未经允许,请勿转载。