Skip to content

Commit

Permalink
Add equals
Browse files Browse the repository at this point in the history
  • Loading branch information
mcm001 committed Jul 28, 2023
1 parent 92eae41 commit 2ebd4af
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,53 @@ public Packet populatePacket(Packet packet) {
packet.encode(ambiguity);
return packet;
}

@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + (isPresent ? 1231 : 1237);
result = prime * result + ((best == null) ? 0 : best.hashCode());
long temp;
temp = Double.doubleToLongBits(bestReprojErr);
result = prime * result + (int) (temp ^ (temp >>> 32));
result = prime * result + ((alt == null) ? 0 : alt.hashCode());
temp = Double.doubleToLongBits(altReprojErr);
result = prime * result + (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits(ambiguity);
result = prime * result + (int) (temp ^ (temp >>> 32));
return result;
}

@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
PNPResults other = (PNPResults) obj;
if (isPresent != other.isPresent)
return false;
if (best == null) {
if (other.best != null)
return false;
} else if (!best.equals(other.best))
return false;
if (Double.doubleToLongBits(bestReprojErr) != Double.doubleToLongBits(other.bestReprojErr))
return false;
if (alt == null) {
if (other.alt != null)
return false;
} else if (!alt.equals(other.alt))
return false;
if (Double.doubleToLongBits(altReprojErr) != Double.doubleToLongBits(other.altReprojErr))
return false;
if (Double.doubleToLongBits(ambiguity) != Double.doubleToLongBits(other.ambiguity))
return false;
return true;
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public PhotonPipelineResult(double latencyMillis, List<PhotonTrackedTarget> targ
*
* @param latencyMillis The latency in the pipeline.
* @param targets The list of targets identified by the pipeline.
* @param multiTagResult Result from multi-target PNP.
* @param result Result from multi-target PNP.
*/
public PhotonPipelineResult(
double latencyMillis, List<PhotonTrackedTarget> targets, PNPResults results) {
Expand Down Expand Up @@ -209,20 +209,29 @@ public int hashCode() {

@Override
public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null) return false;
if (getClass() != obj.getClass()) return false;
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
PhotonPipelineResult other = (PhotonPipelineResult) obj;
if (targets == null) {
if (other.targets != null) return false;
} else if (!targets.equals(other.targets)) return false;
if (other.targets != null)
return false;
} else if (!targets.equals(other.targets))
return false;
if (Double.doubleToLongBits(latencyMillis) != Double.doubleToLongBits(other.latencyMillis))
return false;
if (Double.doubleToLongBits(timestampSeconds)
!= Double.doubleToLongBits(other.timestampSeconds)) return false;
if (Double.doubleToLongBits(timestampSeconds) != Double.doubleToLongBits(other.timestampSeconds))
return false;
if (multiTagResult == null) {
if (other.multiTagResult != null) return false;
} else if (!multiTagResult.equals(other.multiTagResult)) return false;
if (other.multiTagResult != null)
return false;
} else if (!multiTagResult.equals(other.multiTagResult))
return false;
return true;
}


}

0 comments on commit 2ebd4af

Please sign in to comment.