From: David ‘Bombe’ Roden Date: Mon, 8 Apr 2013 19:29:17 +0000 (+0200) Subject: Override equals() and hashCode(). X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=2986a1ee6f2ba3cfcd1d40ce117bfe6be5ff02dc;p=xudocci.git Override equals() and hashCode(). --- diff --git a/src/main/java/net/pterodactylus/xdcc/data/Network.java b/src/main/java/net/pterodactylus/xdcc/data/Network.java index 17453a1..8fac0ea 100644 --- a/src/main/java/net/pterodactylus/xdcc/data/Network.java +++ b/src/main/java/net/pterodactylus/xdcc/data/Network.java @@ -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()); }