X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fxdcc%2Fdata%2FBot.java;h=96d91b654ef57b38a08d44cc4384f6f6da484856;hb=7bbf28951def7e9124fb691d989de0131037b766;hp=33bec206c271ac8ca2e28070becc76ce296a0e25;hpb=118763df651faf501ce55d9cd09bbebf00654e8b;p=xudocci.git
diff --git a/src/main/java/net/pterodactylus/xdcc/data/Bot.java b/src/main/java/net/pterodactylus/xdcc/data/Bot.java
index 33bec20..96d91b6 100644
--- a/src/main/java/net/pterodactylus/xdcc/data/Bot.java
+++ b/src/main/java/net/pterodactylus/xdcc/data/Bot.java
@@ -17,10 +17,13 @@
package net.pterodactylus.xdcc.data;
+import static com.google.common.base.Preconditions.checkNotNull;
+
import java.util.Collection;
+import java.util.Iterator;
import java.util.Map;
-import com.beust.jcommander.internal.Maps;
+import com.google.common.collect.Maps;
/**
* A bot is a client in a {@link Network} that carries {@link Pack}s which are
@@ -28,7 +31,7 @@ import com.beust.jcommander.internal.Maps;
*
* @author David âBombeâ Roden
*/
-public class Bot {
+public class Bot implements Iterable {
/** The network this bot is on. */
private final Network network;
@@ -44,9 +47,12 @@ public class Bot {
*
* @param network
* The network the bot is on
+ * @param name
+ * The name of the bot
*/
- public Bot(Network network) {
- this.network = network;
+ public Bot(Network network, String name) {
+ this.network = checkNotNull(network, "network must not be null");
+ this.name = checkNotNull(name, "name must not be null");
}
//
@@ -92,7 +98,7 @@ public class Bot {
* @return This bot
*/
public Bot name(String name) {
- this.name = name;
+ this.name = checkNotNull(name, "name must not be null");
return this;
}
@@ -111,10 +117,33 @@ public class Bot {
}
//
+ // ITERABLE METHODS
+ //
+
+ @Override
+ public Iterator iterator() {
+ return packs.values().iterator();
+ }
+
+ //
// OBJECT METHODS
//
@Override
+ public boolean equals(Object object) {
+ if (!(object instanceof Bot)) {
+ return false;
+ }
+ Bot bot = (Bot) object;
+ return network().equals(bot.network()) && name().equals(bot.name());
+ }
+
+ @Override
+ public int hashCode() {
+ return network().hashCode() ^ name().hashCode();
+ }
+
+ @Override
public String toString() {
return String.format("%s/%s", name(), network().name());
}