minor fixes to Endpoint
Change-Id: Ia189d96919adb581a1a345b6f74b027ccf01ad79
diff --git a/utils/netty/src/main/java/org/onlab/netty/Endpoint.java b/utils/netty/src/main/java/org/onlab/netty/Endpoint.java
index d6a87b5..660f2b9 100644
--- a/utils/netty/src/main/java/org/onlab/netty/Endpoint.java
+++ b/utils/netty/src/main/java/org/onlab/netty/Endpoint.java
@@ -1,5 +1,9 @@
package org.onlab.netty;
+import java.util.Objects;
+
+import com.google.common.base.MoreObjects;
+
/**
* Representation of a TCP/UDP communication end point.
*/
@@ -32,16 +36,15 @@
@Override
public String toString() {
- return "Endpoint [port=" + port + ", host=" + host + "]";
+ return MoreObjects.toStringHelper(getClass())
+ .add("port", port)
+ .add("host", host)
+ .toString();
}
@Override
public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((host == null) ? 0 : host.hashCode());
- result = prime * result + port;
- return result;
+ return Objects.hash(host, port);
}
@Override
@@ -55,17 +58,8 @@
if (getClass() != obj.getClass()) {
return false;
}
- Endpoint other = (Endpoint) obj;
- if (host == null) {
- if (other.host != null) {
- return false;
- }
- } else if (!host.equals(other.host)) {
- return false;
- }
- if (port != other.port) {
- return false;
- }
- return true;
+ Endpoint that = (Endpoint) obj;
+ return Objects.equals(this.port, that.port) &&
+ Objects.equals(this.host, that.host);
}
}