[ONOS-4718] Add toString, equals, hashCode for LISP control message
Change-Id: I722ab27f50074af26ea92503aac237dec0c64bcf
diff --git a/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/DefaultLispMapRegister.java b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/DefaultLispMapRegister.java
index 8363e83..bbfe3b9 100644
--- a/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/DefaultLispMapRegister.java
+++ b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/DefaultLispMapRegister.java
@@ -15,6 +15,7 @@
*/
package org.onosproject.lisp.msg.protocols;
+import com.google.common.base.Objects;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import io.netty.buffer.ByteBuf;
@@ -22,6 +23,8 @@
import java.util.List;
+import static com.google.common.base.MoreObjects.toStringHelper;
+
/**
* Default LISP map register message class.
*/
@@ -109,6 +112,42 @@
return ImmutableList.copyOf(mapRecords);
}
+ @Override
+ public String toString() {
+ return toStringHelper(this)
+ .add("type", getType())
+ .add("nonce", nonce)
+ .add("recordCount", recordCount)
+ .add("keyId", keyId)
+ .add("mapRecords", mapRecords)
+ .add("proxyMapReply", proxyMapReply)
+ .add("wantMapNotify", wantMapNotify).toString();
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+
+ DefaultLispMapRegister that = (DefaultLispMapRegister) o;
+ return Objects.equal(nonce, that.nonce) &&
+ Objects.equal(recordCount, that.recordCount) &&
+ Objects.equal(keyId, that.keyId) &&
+ Objects.equal(authenticationData, that.authenticationData) &&
+ Objects.equal(proxyMapReply, that.proxyMapReply) &&
+ Objects.equal(wantMapNotify, that.wantMapNotify);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(nonce, recordCount, keyId, authenticationData,
+ proxyMapReply, wantMapNotify);
+ }
+
public static final class DefaultRegisterBuilder implements RegisterBuilder {
private long nonce;