本文整理汇总了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;
}
示例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;
}
示例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());
}