mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-05 03:53:44 +02:00
reimplement VirtualNetworkRoute.equals
This commit is contained in:
parent
4ca8d9861d
commit
27d44f8edb
1 changed files with 52 additions and 25 deletions
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue