nl.vpro.domain.user.Broadcasters Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of user-domain Show documentation
Show all versions of user-domain Show documentation
Domain classes and interfaces related to accountability, users and organizations.
package nl.vpro.domain.user;
import java.util.*;
import nl.vpro.domain.NotFoundException;
/**
* @author Michiel Meeuwissen
*/
public final class Broadcasters {
private Broadcasters() {
// no instances for this
}
public static List match(BroadcasterService broadcasterService, List broadcasters) throws NotFoundException {
List result = new ArrayList<>(broadcasters.size());
for (Broadcaster b : broadcasters) {
if (b.getId() != null) {
result.add(broadcasterService.find(b.getId()));
} else if (b.getWhatsOnId() != null) {
result.add(broadcasterService.findForWhatsOnId(b.getWhatsOnId()));
} else if (b.getNeboId() != null) {
result.add(broadcasterService.findForNeboId(b.getNeboId()));
} else {
result.add(b);
}
}
return result;
}
public static Optional getByAnyId(BroadcasterService broadcasterService, String id) {
Broadcaster byId = broadcasterService.find(id);
if (byId != null ) {
return Optional.of(byId);
}
return broadcasterService.findAll()
.stream()
.filter(b -> b.getWhatsOnId().equals(id) || b.getNeboId().equals(id) || b.getMisId().equals(id)
)
.findFirst();
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy