Yuta HIGUCHI

minor fixes to Endpoint

Change-Id: Ia189d96919adb581a1a345b6f74b027ccf01ad79
1 package org.onlab.netty; 1 package org.onlab.netty;
2 2
3 +import java.util.Objects;
4 +
5 +import com.google.common.base.MoreObjects;
6 +
3 /** 7 /**
4 * Representation of a TCP/UDP communication end point. 8 * Representation of a TCP/UDP communication end point.
5 */ 9 */
...@@ -32,16 +36,15 @@ public class Endpoint { ...@@ -32,16 +36,15 @@ public class Endpoint {
32 36
33 @Override 37 @Override
34 public String toString() { 38 public String toString() {
35 - return "Endpoint [port=" + port + ", host=" + host + "]"; 39 + return MoreObjects.toStringHelper(getClass())
40 + .add("port", port)
41 + .add("host", host)
42 + .toString();
36 } 43 }
37 44
38 @Override 45 @Override
39 public int hashCode() { 46 public int hashCode() {
40 - final int prime = 31; 47 + return Objects.hash(host, port);
41 - int result = 1;
42 - result = prime * result + ((host == null) ? 0 : host.hashCode());
43 - result = prime * result + port;
44 - return result;
45 } 48 }
46 49
47 @Override 50 @Override
...@@ -55,17 +58,8 @@ public class Endpoint { ...@@ -55,17 +58,8 @@ public class Endpoint {
55 if (getClass() != obj.getClass()) { 58 if (getClass() != obj.getClass()) {
56 return false; 59 return false;
57 } 60 }
58 - Endpoint other = (Endpoint) obj; 61 + Endpoint that = (Endpoint) obj;
59 - if (host == null) { 62 + return Objects.equals(this.port, that.port) &&
60 - if (other.host != null) { 63 + Objects.equals(this.host, that.host);
61 - return false;
62 - }
63 - } else if (!host.equals(other.host)) {
64 - return false;
65 - }
66 - if (port != other.port) {
67 - return false;
68 - }
69 - return true;
70 } 64 }
71 } 65 }
......