如何将List转换为GroupMatcher?
我的代码就像这样。
List<String> jobGroupNames = scheduler.getJobGroupNames();
现在我要检查
for (GroupMatcher<JobKey> jobGroup : jobGroupNames) {
}
这里jobGroupNames是List,所以我得到了这个错误
Type mismatch: cannot convert from element type String to GroupMatcher<JobKey>
答案 0 :(得分:0)
jobGroupNames is a list of String, That's why you should iterate like below.
// loop jobs by group
List<String> jobGroupNames = scheduler.getJobGroupNames();
for (String groupName : jobGroupNames ) {
// And to get Job keys :
for (JobKey jobKey : scheduler.getJobKeys(GroupMatcher.jobGroupEquals(groupName))) {
}
}