javalistspring-mvcquartz-schedulerscheduler

How can I convert List<String> to GroupMatcher<JobKey>


How to convert List to GroupMatcher ?

My code Just Like This.

List<String> jobGroupNames = scheduler.getJobGroupNames();

Now I want to check

for (GroupMatcher<JobKey> jobGroup : jobGroupNames) {
}

Here jobGroupNames is List, So I'm Getting this error

Type mismatch: cannot convert from element type String to GroupMatcher<JobKey>

Solution

  • 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))) {
        }
    }