Priyanka B
Committed by Ray Milkey

Compare fix

Change-Id: I56ad744ff9d99198136c97f62896c487285192ec
......@@ -238,6 +238,7 @@ public class BgpPrefixLSIdentifier implements Comparable<Object> {
return 0;
}
int result = this.localNodeDescriptors.compareTo(((BgpPrefixLSIdentifier) o).localNodeDescriptors);
boolean tlvFound = false;
if (result != 0) {
return result;
} else {
......@@ -252,17 +253,21 @@ public class BgpPrefixLSIdentifier implements Comparable<Object> {
}
ListIterator<BgpValueType> listIterator = prefixDescriptor.listIterator();
ListIterator<BgpValueType> listIteratorOther = ((BgpPrefixLSIdentifier) o).prefixDescriptor.listIterator();
while (listIterator.hasNext()) {
BgpValueType tlv = listIterator.next();
if (prefixDescriptor.contains(tlv) && ((BgpPrefixLSIdentifier) o).prefixDescriptor.contains(tlv)) {
int res = prefixDescriptor.get(prefixDescriptor.indexOf(tlv)).compareTo(
BgpValueType tlv1 = listIterator.next();
for (BgpValueType tlv : ((BgpPrefixLSIdentifier) o).prefixDescriptor) {
if (tlv.getType() == tlv1.getType()) {
result = prefixDescriptor.get(prefixDescriptor.indexOf(tlv1)).compareTo(
((BgpPrefixLSIdentifier) o).prefixDescriptor
.get(((BgpPrefixLSIdentifier) o).prefixDescriptor.indexOf(tlv)));
if (res != 0) {
return res;
if (result != 0) {
return result;
}
} else {
tlvFound = true;
break;
}
}
if (!tlvFound) {
return 1;
}
}
......
......@@ -234,14 +234,20 @@ public class NodeDescriptors {
.toString();
}
/**
* Compares this and o object.
*
* @param o object to be compared with this object
* @return which object is greater
*/
public int compareTo(Object o) {
if (this.equals(o)) {
return 0;
}
ListIterator<BgpValueType> listIterator = subTlvs.listIterator();
ListIterator<BgpValueType> listIteratorOther = ((NodeDescriptors) o).subTlvs.listIterator();
int countOtherSubTlv = ((NodeDescriptors) o).subTlvs.size();
int countObjSubTlv = subTlvs.size();
boolean tlvFound = false;
if (countOtherSubTlv != countObjSubTlv) {
if (countOtherSubTlv > countObjSubTlv) {
return 1;
......@@ -250,15 +256,20 @@ public class NodeDescriptors {
}
} else {
while (listIterator.hasNext()) {
BgpValueType tlv = listIterator.next();
BgpValueType tlv1 = listIterator.next();
log.debug("NodeDescriptor compare subtlv's");
if (subTlvs.contains(tlv) && ((NodeDescriptors) o).subTlvs.contains(tlv)) {
int result = subTlvs.get(subTlvs.indexOf(tlv)).compareTo(
for (BgpValueType tlv : ((NodeDescriptors) o).subTlvs) {
if (tlv.getType() == tlv1.getType()) {
int result = subTlvs.get(subTlvs.indexOf(tlv1)).compareTo(
((NodeDescriptors) o).subTlvs.get(((NodeDescriptors) o).subTlvs.indexOf(tlv)));
if (result != 0) {
return result;
}
} else {
tlvFound = true;
break;
}
}
if (!tlvFound) {
return 1;
}
}
......