Make channels work correctly in maps and sets.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 10 Apr 2013 06:24:39 +0000 (08:24 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 10 Apr 2013 06:26:14 +0000 (08:26 +0200)
src/main/java/net/pterodactylus/xdcc/data/Channel.java

index 59be331..93ebfa0 100644 (file)
@@ -65,4 +65,28 @@ public class Channel {
                return name;
        }
 
+       //
+       // OBJECT METHODS
+       //
+
+       @Override
+       public boolean equals(Object object) {
+               if (!(object instanceof Channel)) {
+                       return false;
+               }
+               Channel channel = (Channel) object;
+               if (!network().equals(channel.network())) {
+                       return false;
+               }
+               if (!name().equalsIgnoreCase(channel.name())) {
+                       return false;
+               }
+               return true;
+       }
+
+       @Override
+       public int hashCode() {
+               return network().hashCode() ^ name().hashCode();
+       }
+
 }