Jian Li
Committed by Ray Milkey

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

Change-Id: I722ab27f50074af26ea92503aac237dec0c64bcf
......@@ -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 org.onlab.util.ImmutableByteSequence;
import java.util.List;
import static com.google.common.base.MoreObjects.toStringHelper;
/**
* Default LISP map notify message class.
*/
......@@ -91,6 +94,36 @@ public final class DefaultLispMapNotify implements LispMapNotify {
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).toString();
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
DefaultLispMapNotify that = (DefaultLispMapNotify) o;
return Objects.equal(nonce, that.nonce) &&
Objects.equal(recordCount, that.recordCount) &&
Objects.equal(keyId, that.keyId) &&
Objects.equal(authenticationData, that.authenticationData);
}
@Override
public int hashCode() {
return Objects.hashCode(nonce, recordCount, keyId, authenticationData);
}
public static final class DefaultNotifyBuilder implements NotifyBuilder {
private long nonce;
......
......@@ -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 org.onlab.util.ImmutableByteSequence;
import java.util.List;
import static com.google.common.base.MoreObjects.toStringHelper;
/**
* Default LISP map register message class.
*/
......@@ -109,6 +112,42 @@ public final class DefaultLispMapRegister implements LispMapRegister {
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;
......
......@@ -15,8 +15,11 @@
*/
package org.onosproject.lisp.msg.protocols;
import com.google.common.base.Objects;
import io.netty.buffer.ByteBuf;
import static com.google.common.base.MoreObjects.toStringHelper;
/**
* Default LISP map reply message class.
*/
......@@ -86,6 +89,38 @@ public final class DefaultLispMapReply implements LispMapReply {
return this.nonce;
}
@Override
public String toString() {
return toStringHelper(this)
.add("type", getType())
.add("nonce", nonce)
.add("recordCount", recordCount)
.add("probe", probe)
.add("etr", etr)
.add("security", security).toString();
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
DefaultLispMapReply that = (DefaultLispMapReply) o;
return Objects.equal(nonce, that.nonce) &&
Objects.equal(recordCount, that.recordCount) &&
Objects.equal(probe, that.probe) &&
Objects.equal(etr, that.etr) &&
Objects.equal(security, that.security);
}
@Override
public int hashCode() {
return Objects.hashCode(nonce, recordCount, probe, etr, security);
}
public static final class DefaultReplyBuilder implements ReplyBuilder {
private long nonce;
......
......@@ -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 org.onosproject.lisp.msg.types.LispAfiAddress;
import java.util.List;
import static com.google.common.base.MoreObjects.toStringHelper;
/**
* Default LISP map request message class.
*/
......@@ -141,6 +144,51 @@ public final class DefaultLispMapRequest implements LispMapRequest {
return ImmutableList.copyOf(eidRecords);
}
@Override
public String toString() {
return toStringHelper(this)
.add("type", getType())
.add("nonce", nonce)
.add("recordCount", recordCount)
.add("source EID", sourceEid)
.add("ITR rlocs", itrRlocs)
.add("EID records", eidRecords)
.add("authoritative", authoritative)
.add("mapDataPresent", mapDataPresent)
.add("probe", probe)
.add("SMR", smr)
.add("Proxy ITR", pitr)
.add("SMR Invoked", smrInvoked).toString();
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
DefaultLispMapRequest that = (DefaultLispMapRequest) o;
return Objects.equal(nonce, that.nonce) &&
Objects.equal(recordCount, that.recordCount) &&
Objects.equal(sourceEid, that.sourceEid) &&
Objects.equal(itrRlocs, that.itrRlocs) &&
Objects.equal(eidRecords, that.eidRecords) &&
Objects.equal(authoritative, that.authoritative) &&
Objects.equal(mapDataPresent, that.mapDataPresent) &&
Objects.equal(probe, that.probe) &&
Objects.equal(smr, that.smr) &&
Objects.equal(pitr, that.pitr) &&
Objects.equal(smrInvoked, that.smrInvoked);
}
@Override
public int hashCode() {
return Objects.hashCode(nonce, recordCount, sourceEid, itrRlocs, eidRecords,
authoritative, mapDataPresent, probe, smr, pitr, smrInvoked);
}
public static final class DefaultRequestBuilder implements RequestBuilder {
private long nonce;
......