use of cn.hutool.core.collection.CollectionUtil in project fast-request by dromara.
the class AllApisNavToolWindow method refreshFilterModule.
public void refreshFilterModule(List<String> selectModule, List<String> selectMethodType) {
DumbService.getInstance(myProject).smartInvokeLater(() -> {
Task.Backgroundable task = new Task.Backgroundable(myProject, "Reload apis...") {
@Override
public void run(@NotNull ProgressIndicator indicator) {
indicator.setIndeterminate(false);
ApplicationManager.getApplication().runReadAction(() -> {
if (allApiList == null) {
return;
}
List<ApiService> filterList = allApiList.stream().filter(q -> selectModule.contains(q.getModuleName())).collect(Collectors.toList());
indicator.setText("Rendering");
List<ApiService.ApiMethod> filterMethodList = new ArrayList<>();
filterList.stream().map(ApiService::getApiMethodList).filter(CollectionUtil::isNotEmpty).forEach(filterMethodList::addAll);
long count = filterMethodList.stream().filter(q -> selectMethodType.contains(q.getMethodType())).count();
RootNode root = new RootNode(count + " apis") {
};
NodeUtil.convertToRoot(root, NodeUtil.convertToMap(filterList.stream().filter(q -> CollectionUtil.isNotEmpty(q.getApiMethodList())).filter(q -> q.getApiMethodList().stream().anyMatch(p -> selectMethodType.contains(p.getMethodType()))).collect(Collectors.toList())), selectMethodType);
apiTree.setModel(new DefaultTreeModel(root));
});
}
};
ProgressManager.getInstance().runProcessWithProgressAsynchronously(task, new BackgroundableProcessIndicator(task));
});
}
Aggregations