如何将List <string>转换为GroupMatcher <jobkey>

时间:2016-11-21 06:31:34

标签: java list spring-mvc quartz-scheduler scheduler

如何将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>

1 个答案:

答案 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))) {
    }
}