zeji zeji - 13 days ago 7
Java Question

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>

Answer
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))) {
    }
}
Comments