From 2986a1ee6f2ba3cfcd1d40ce117bfe6be5ff02dc Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Mon, 8 Apr 2013 21:29:17 +0200 Subject: [PATCH] Override equals() and hashCode(). --- src/main/java/net/pterodactylus/xdcc/data/Network.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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()); } -- 2.7.4