reimplement VirtualNetworkRoute.equals

This commit is contained in:
Brenton Bostick 2023-02-02 17:05:52 -05:00 committed by Sean OMeara
parent 4ca8d9861d
commit 27d44f8edb

View file

@ -73,36 +73,63 @@ public final class VirtualNetworkRoute implements Comparable<VirtualNetworkRoute
return this.toString().compareTo(other.toString()); return this.toString().compareTo(other.toString());
} }
public boolean equals(VirtualNetworkRoute other) { @Override
boolean targetEquals = false; public boolean equals(Object o) {
if (target == null && other.target == null) {
targetEquals = true; if (!(o instanceof VirtualNetworkRoute)) {
} return false;
else if (target == null && other.target != null) {
targetEquals = false;
}
else if (target != null && other.target == null) {
targetEquals = false;
}
else {
targetEquals = target.toString().equals(other.target.toString());
} }
VirtualNetworkRoute other = (VirtualNetworkRoute) o;
boolean targetEquals;
if (target == null) {
//noinspection RedundantIfStatement
if (other.target == null) {
targetEquals = true;
} else {
targetEquals = false;
}
} else {
if (other.target == null) {
targetEquals = false;
} else {
targetEquals = target.equals(other.target);
}
}
if (!targetEquals) {
return false;
}
boolean viaEquals; boolean viaEquals;
if (via == null && other.via == null) { if (via == null) {
viaEquals = true; //noinspection RedundantIfStatement
} if (other.via == null) {
else if (via == null && other.via != null) { viaEquals = true;
viaEquals = false; } else {
} viaEquals = false;
else if (via != null && other.via == null) { }
viaEquals = false; } else {
} if (other.via == null) {
else { viaEquals = false;
viaEquals = via.toString().equals(other.via.toString()); } else {
viaEquals = via.equals(other.via);
}
} }
return viaEquals && targetEquals; if (!viaEquals) {
return false;
}
if (flags != other.flags) {
return false;
}
if (metric != other.metric) {
return false;
}
return true;
} }
} }