io.github.jaylondev.swift.boot.test.collect.ClassCollectService Maven / Gradle / Ivy
package io.github.jaylondev.swift.boot.test.collect;
import java.util.*;
import java.util.stream.Collectors;
/**
* @author jaylon 2023/8/7 22:24
*/
public class ClassCollectService {
/**
* 收集启动单元测试需要在容器中装载的class
* @param collectContext 上下文对象
* @return 收集结果集合
*/
public static Set> collect(CollectContext collectContext) {
List handlerList = getSubHandlerSortedList();
handlerList.forEach(handler -> handler.collect(collectContext));
return collectContext.getInjectClassList();
}
/**
* 获取类收集器
*/
private static List getSubHandlerSortedList() {
ServiceLoader services = ServiceLoader.load(ICollectHandler.class);
List sortedServices = new ArrayList<>();
for (ICollectHandler service : services) {
sortedServices.add(service);
}
return sortedServices.stream()
.sorted(Comparator.comparingInt(ICollectHandler::getOrder))
.collect(Collectors.toList());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy