本文整理匯總了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());
}