Override equals() and hashCode().
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Mon, 8 Apr 2013 19:29:17 +0000 (21:29 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Mon, 8 Apr 2013 19:29:17 +0000 (21:29 +0200)
src/main/java/net/pterodactylus/xdcc/data/Network.java

index 17453a1..8fac0ea 100644 (file)
@@ -20,6 +20,7 @@ package net.pterodactylus.xdcc.data;
 import java.util.Collection;
 
 import com.beust.jcommander.internal.Sets;
+import com.google.common.base.Objects;
 
 /**
  * Defines a network.
@@ -79,6 +80,23 @@ public class Network {
        //
 
        @Override
+       public boolean equals(Object object) {
+               if (!(object instanceof Network)) {
+                       return false;
+               }
+               Network network = (Network) object;
+               if (!Objects.equal(name(), network.name())) {
+                       return false;
+               }
+               return true;
+       }
+
+       @Override
+       public int hashCode() {
+               return name().hashCode();
+       }
+
+       @Override
        public String toString() {
                return String.format("%s(%d servers)", name(), servers().size());
        }