com.breuninger.boot.jobs.service.JobMutexGroups Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of spring-boot-starter-breuninger-jobs Show documentation
Show all versions of spring-boot-starter-breuninger-jobs Show documentation
spring-boot-starter-breuninger-jobs
package com.breuninger.boot.jobs.service;
import static java.util.Collections.emptySet;
import java.util.HashSet;
import java.util.Set;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class JobMutexGroups {
private Set mutexGroups = emptySet();
public Set getMutexGroups() {
return mutexGroups;
}
@Autowired(required = false)
public void setMutexGroups(final Set mutexGroups) {
this.mutexGroups = mutexGroups;
}
public Set mutexJobTypesFor(final String jobType) {
final Set result = new HashSet<>();
mutexGroups.stream().map(JobMutexGroup::getJobTypes).filter(g -> g.contains(jobType)).forEach(result::addAll);
result.remove(jobType);
return result;
}
}