package org.royaldev.thehumanity.server.services.client;
import org.jetbrains.annotations.NotNull;
import org.kitteh.irc.client.library.Client;
import org.royaldev.thehumanity.TheHumanity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
@Service
public class HumanityClientService implements ClientService {
@Autowired
private TheHumanity humanity;
@Override
public List<Client> getClients() {
return this.humanity.getClients();
}
@Override
public Client getFromHostname(@NotNull final String hostname) {
return this.humanity.getClientServerMap().entrySet().stream().filter(entry -> entry.getValue().getHost().equalsIgnoreCase(hostname)).map(Map.Entry::getKey).findFirst().orElse(null);
}
}