Incomplete RESTful API for IRC
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

ServerManager.java 755B

123456789101112131415161718192021222324252627282930313233
  1. package name.smith.chris.restirc.model;
  2. import java.util.Collection;
  3. import java.util.Collections;
  4. import java.util.HashMap;
  5. import java.util.Map;
  6. /**
  7. * Manages a collection of servers.
  8. */
  9. public class ServerManager {
  10. private final Map<String, Server> servers
  11. = Collections.synchronizedMap(new HashMap<String, Server>());
  12. public boolean hasServer(String id) {
  13. return servers.containsKey(id);
  14. }
  15. public Server getServer(String id) {
  16. return servers.get(id);
  17. }
  18. public void addServer(String id, Server server) {
  19. servers.put(id, server);
  20. server.connect();
  21. }
  22. public Collection<String> getAllIds() {
  23. return Collections.unmodifiableCollection(servers.keySet());
  24. }
  25. }