Skip to content

Commit

Permalink
Make eq/hc null safe
Browse files Browse the repository at this point in the history
  • Loading branch information
optionsome committed May 17, 2024
1 parent 22a9763 commit e9d5d3d
Showing 1 changed file with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ public Duration searchWindowUsed() {
@Override
public int hashCode() {
return Objects.hash(
startCursor.getValue(),
endCursor.getValue(),
startCursor != null ? startCursor.getValue() : null,
endCursor != null ? endCursor.getValue() : null,
hasPreviousPage,
hasNextPage,
searchWindowUsed
Expand All @@ -67,8 +67,22 @@ public boolean equals(Object o) {
}
PlanPageInfo that = (PlanPageInfo) o;
return (
Objects.equals(startCursor.getValue(), that.startCursor.getValue()) &&
Objects.equals(endCursor.getValue(), that.endCursor.getValue()) &&
(
(startCursor == null && that.startCursor == null) ||
(
startCursor != null &&
that.startCursor != null &&
Objects.equals(startCursor.getValue(), that.startCursor.getValue())
)
) &&
(
(endCursor == null && that.endCursor == null) ||
(
endCursor != null &&
that.endCursor != null &&
Objects.equals(endCursor.getValue(), that.endCursor.getValue())
)
) &&
Objects.equals(searchWindowUsed, that.searchWindowUsed) &&
hasPreviousPage == that.hasPreviousPage &&
hasNextPage == that.hasNextPage
Expand Down

0 comments on commit e9d5d3d

Please sign in to comment.