Note that StatusOr containing statuses, the equality comparision is delegated to Status#equals which just does a reference equality check because equality on Statuses is not well defined. Instead, do comparison based on their Code with Status#getCode. The description and cause of th
(Object other)
| 75 | * in the future. |
| 76 | */ |
| 77 | @Override |
| 78 | public boolean equals(Object other) { |
| 79 | if (!(other instanceof StatusOr)) { |
| 80 | return false; |
| 81 | } |
| 82 | StatusOr<?> otherStatus = (StatusOr<?>) other; |
| 83 | if (hasValue() != otherStatus.hasValue()) { |
| 84 | return false; |
| 85 | } |
| 86 | if (hasValue()) { |
| 87 | return Objects.equal(value, otherStatus.value); |
| 88 | } |
| 89 | return Objects.equal(status, otherStatus.status); |
| 90 | } |
| 91 | |
| 92 | @Override |
| 93 | public int hashCode() { |