Jian Li
Committed by Ray Milkey

[ONOS-4718] Add toString, equals, hashCode for LISP control message

Change-Id: I722ab27f50074af26ea92503aac237dec0c64bcf
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
15 */ 15 */
16 package org.onosproject.lisp.msg.protocols; 16 package org.onosproject.lisp.msg.protocols;
17 17
18 +import com.google.common.base.Objects;
18 import com.google.common.collect.ImmutableList; 19 import com.google.common.collect.ImmutableList;
19 import com.google.common.collect.Lists; 20 import com.google.common.collect.Lists;
20 import io.netty.buffer.ByteBuf; 21 import io.netty.buffer.ByteBuf;
...@@ -22,6 +23,8 @@ import org.onlab.util.ImmutableByteSequence; ...@@ -22,6 +23,8 @@ import org.onlab.util.ImmutableByteSequence;
22 23
23 import java.util.List; 24 import java.util.List;
24 25
26 +import static com.google.common.base.MoreObjects.toStringHelper;
27 +
25 /** 28 /**
26 * Default LISP map notify message class. 29 * Default LISP map notify message class.
27 */ 30 */
...@@ -91,6 +94,36 @@ public final class DefaultLispMapNotify implements LispMapNotify { ...@@ -91,6 +94,36 @@ public final class DefaultLispMapNotify implements LispMapNotify {
91 return ImmutableList.copyOf(mapRecords); 94 return ImmutableList.copyOf(mapRecords);
92 } 95 }
93 96
97 + @Override
98 + public String toString() {
99 + return toStringHelper(this)
100 + .add("type", getType())
101 + .add("nonce", nonce)
102 + .add("recordCount", recordCount)
103 + .add("keyId", keyId)
104 + .add("mapRecords", mapRecords).toString();
105 + }
106 +
107 + @Override
108 + public boolean equals(Object o) {
109 + if (this == o) {
110 + return true;
111 + }
112 + if (o == null || getClass() != o.getClass()) {
113 + return false;
114 + }
115 + DefaultLispMapNotify that = (DefaultLispMapNotify) o;
116 + return Objects.equal(nonce, that.nonce) &&
117 + Objects.equal(recordCount, that.recordCount) &&
118 + Objects.equal(keyId, that.keyId) &&
119 + Objects.equal(authenticationData, that.authenticationData);
120 + }
121 +
122 + @Override
123 + public int hashCode() {
124 + return Objects.hashCode(nonce, recordCount, keyId, authenticationData);
125 + }
126 +
94 public static final class DefaultNotifyBuilder implements NotifyBuilder { 127 public static final class DefaultNotifyBuilder implements NotifyBuilder {
95 128
96 private long nonce; 129 private long nonce;
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
15 */ 15 */
16 package org.onosproject.lisp.msg.protocols; 16 package org.onosproject.lisp.msg.protocols;
17 17
18 +import com.google.common.base.Objects;
18 import com.google.common.collect.ImmutableList; 19 import com.google.common.collect.ImmutableList;
19 import com.google.common.collect.Lists; 20 import com.google.common.collect.Lists;
20 import io.netty.buffer.ByteBuf; 21 import io.netty.buffer.ByteBuf;
...@@ -22,6 +23,8 @@ import org.onlab.util.ImmutableByteSequence; ...@@ -22,6 +23,8 @@ import org.onlab.util.ImmutableByteSequence;
22 23
23 import java.util.List; 24 import java.util.List;
24 25
26 +import static com.google.common.base.MoreObjects.toStringHelper;
27 +
25 /** 28 /**
26 * Default LISP map register message class. 29 * Default LISP map register message class.
27 */ 30 */
...@@ -109,6 +112,42 @@ public final class DefaultLispMapRegister implements LispMapRegister { ...@@ -109,6 +112,42 @@ public final class DefaultLispMapRegister implements LispMapRegister {
109 return ImmutableList.copyOf(mapRecords); 112 return ImmutableList.copyOf(mapRecords);
110 } 113 }
111 114
115 + @Override
116 + public String toString() {
117 + return toStringHelper(this)
118 + .add("type", getType())
119 + .add("nonce", nonce)
120 + .add("recordCount", recordCount)
121 + .add("keyId", keyId)
122 + .add("mapRecords", mapRecords)
123 + .add("proxyMapReply", proxyMapReply)
124 + .add("wantMapNotify", wantMapNotify).toString();
125 + }
126 +
127 + @Override
128 + public boolean equals(Object o) {
129 + if (this == o) {
130 + return true;
131 + }
132 + if (o == null || getClass() != o.getClass()) {
133 + return false;
134 + }
135 +
136 + DefaultLispMapRegister that = (DefaultLispMapRegister) o;
137 + return Objects.equal(nonce, that.nonce) &&
138 + Objects.equal(recordCount, that.recordCount) &&
139 + Objects.equal(keyId, that.keyId) &&
140 + Objects.equal(authenticationData, that.authenticationData) &&
141 + Objects.equal(proxyMapReply, that.proxyMapReply) &&
142 + Objects.equal(wantMapNotify, that.wantMapNotify);
143 + }
144 +
145 + @Override
146 + public int hashCode() {
147 + return Objects.hashCode(nonce, recordCount, keyId, authenticationData,
148 + proxyMapReply, wantMapNotify);
149 + }
150 +
112 public static final class DefaultRegisterBuilder implements RegisterBuilder { 151 public static final class DefaultRegisterBuilder implements RegisterBuilder {
113 152
114 private long nonce; 153 private long nonce;
......
...@@ -15,8 +15,11 @@ ...@@ -15,8 +15,11 @@
15 */ 15 */
16 package org.onosproject.lisp.msg.protocols; 16 package org.onosproject.lisp.msg.protocols;
17 17
18 +import com.google.common.base.Objects;
18 import io.netty.buffer.ByteBuf; 19 import io.netty.buffer.ByteBuf;
19 20
21 +import static com.google.common.base.MoreObjects.toStringHelper;
22 +
20 /** 23 /**
21 * Default LISP map reply message class. 24 * Default LISP map reply message class.
22 */ 25 */
...@@ -86,6 +89,38 @@ public final class DefaultLispMapReply implements LispMapReply { ...@@ -86,6 +89,38 @@ public final class DefaultLispMapReply implements LispMapReply {
86 return this.nonce; 89 return this.nonce;
87 } 90 }
88 91
92 + @Override
93 + public String toString() {
94 + return toStringHelper(this)
95 + .add("type", getType())
96 + .add("nonce", nonce)
97 + .add("recordCount", recordCount)
98 + .add("probe", probe)
99 + .add("etr", etr)
100 + .add("security", security).toString();
101 + }
102 +
103 + @Override
104 + public boolean equals(Object o) {
105 + if (this == o) {
106 + return true;
107 + }
108 + if (o == null || getClass() != o.getClass()) {
109 + return false;
110 + }
111 + DefaultLispMapReply that = (DefaultLispMapReply) o;
112 + return Objects.equal(nonce, that.nonce) &&
113 + Objects.equal(recordCount, that.recordCount) &&
114 + Objects.equal(probe, that.probe) &&
115 + Objects.equal(etr, that.etr) &&
116 + Objects.equal(security, that.security);
117 + }
118 +
119 + @Override
120 + public int hashCode() {
121 + return Objects.hashCode(nonce, recordCount, probe, etr, security);
122 + }
123 +
89 public static final class DefaultReplyBuilder implements ReplyBuilder { 124 public static final class DefaultReplyBuilder implements ReplyBuilder {
90 125
91 private long nonce; 126 private long nonce;
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
15 */ 15 */
16 package org.onosproject.lisp.msg.protocols; 16 package org.onosproject.lisp.msg.protocols;
17 17
18 +import com.google.common.base.Objects;
18 import com.google.common.collect.ImmutableList; 19 import com.google.common.collect.ImmutableList;
19 import com.google.common.collect.Lists; 20 import com.google.common.collect.Lists;
20 import io.netty.buffer.ByteBuf; 21 import io.netty.buffer.ByteBuf;
...@@ -22,6 +23,8 @@ import org.onosproject.lisp.msg.types.LispAfiAddress; ...@@ -22,6 +23,8 @@ import org.onosproject.lisp.msg.types.LispAfiAddress;
22 23
23 import java.util.List; 24 import java.util.List;
24 25
26 +import static com.google.common.base.MoreObjects.toStringHelper;
27 +
25 /** 28 /**
26 * Default LISP map request message class. 29 * Default LISP map request message class.
27 */ 30 */
...@@ -141,6 +144,51 @@ public final class DefaultLispMapRequest implements LispMapRequest { ...@@ -141,6 +144,51 @@ public final class DefaultLispMapRequest implements LispMapRequest {
141 return ImmutableList.copyOf(eidRecords); 144 return ImmutableList.copyOf(eidRecords);
142 } 145 }
143 146
147 + @Override
148 + public String toString() {
149 + return toStringHelper(this)
150 + .add("type", getType())
151 + .add("nonce", nonce)
152 + .add("recordCount", recordCount)
153 + .add("source EID", sourceEid)
154 + .add("ITR rlocs", itrRlocs)
155 + .add("EID records", eidRecords)
156 + .add("authoritative", authoritative)
157 + .add("mapDataPresent", mapDataPresent)
158 + .add("probe", probe)
159 + .add("SMR", smr)
160 + .add("Proxy ITR", pitr)
161 + .add("SMR Invoked", smrInvoked).toString();
162 + }
163 +
164 + @Override
165 + public boolean equals(Object o) {
166 + if (this == o) {
167 + return true;
168 + }
169 + if (o == null || getClass() != o.getClass()) {
170 + return false;
171 + }
172 + DefaultLispMapRequest that = (DefaultLispMapRequest) o;
173 + return Objects.equal(nonce, that.nonce) &&
174 + Objects.equal(recordCount, that.recordCount) &&
175 + Objects.equal(sourceEid, that.sourceEid) &&
176 + Objects.equal(itrRlocs, that.itrRlocs) &&
177 + Objects.equal(eidRecords, that.eidRecords) &&
178 + Objects.equal(authoritative, that.authoritative) &&
179 + Objects.equal(mapDataPresent, that.mapDataPresent) &&
180 + Objects.equal(probe, that.probe) &&
181 + Objects.equal(smr, that.smr) &&
182 + Objects.equal(pitr, that.pitr) &&
183 + Objects.equal(smrInvoked, that.smrInvoked);
184 + }
185 +
186 + @Override
187 + public int hashCode() {
188 + return Objects.hashCode(nonce, recordCount, sourceEid, itrRlocs, eidRecords,
189 + authoritative, mapDataPresent, probe, smr, pitr, smrInvoked);
190 + }
191 +
144 public static final class DefaultRequestBuilder implements RequestBuilder { 192 public static final class DefaultRequestBuilder implements RequestBuilder {
145 193
146 private long nonce; 194 private long nonce;
......