All Downloads are FREE. Search and download functionalities are using the official Maven repository.

nl.vpro.domain.user.Broadcasters Maven / Gradle / Ivy

Go to download

Domain classes and interfaces related to accountability, users and organizations.

There is a newer version: 8.3.1
Show newest version
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