Skip to content

Commit c28f97e

Browse files
committed
Implement hashCode where missing.
1 parent 8525c2d commit c28f97e

3 files changed

Lines changed: 17 additions & 3 deletions

File tree

src/com/google/common/geometry/ParametrizedS2Point.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ public int compareTo(ParametrizedS2Point o) {
5555
return point.compareTo(o.point);
5656
}
5757

58-
@SuppressWarnings("EqualsHashCode")
5958
@Override
6059
public boolean equals(Object other) {
6160
if (other instanceof ParametrizedS2Point) {
@@ -65,4 +64,11 @@ public boolean equals(Object other) {
6564
return false;
6665
}
6766
}
67+
68+
@Override
69+
public int hashCode() {
70+
// TODO(jrosenstock): Use Objects.hash when API 19 (2014-06) is allowed. Current min is 14
71+
// (2011-10). Double.hashCode requires an even higher API level, so just hash the point.
72+
return point.hashCode();
73+
}
6874
}

src/com/google/common/geometry/S2RegionIntersection.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,16 @@ public boolean mayIntersect(S2Cell cell) {
9999
* NOTE: This should be rewritten to disregard order if such functionality is ever required.
100100
*/
101101
@Override
102-
@SuppressWarnings("EqualsHashCode")
103102
public boolean equals(Object thatObject) {
104103
if (!(thatObject instanceof S2RegionIntersection)) {
105104
return false;
106105
}
107106
S2RegionIntersection that = (S2RegionIntersection) thatObject;
108107
return Arrays.deepEquals(regions, that.regions);
109108
}
109+
110+
@Override
111+
public int hashCode() {
112+
return Arrays.hashCode(regions);
113+
}
110114
}

src/com/google/common/geometry/S2RegionUnion.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,16 @@ public boolean mayIntersect(S2Cell cell) {
104104
* should be rewritten to disregard order if such functionality is ever required.
105105
*/
106106
@Override
107-
@SuppressWarnings("EqualsHashCode")
108107
public boolean equals(Object thatObject) {
109108
if (!(thatObject instanceof S2RegionUnion)) {
110109
return false;
111110
}
112111
S2RegionUnion that = (S2RegionUnion) thatObject;
113112
return Arrays.deepEquals(regions, that.regions);
114113
}
114+
115+
@Override
116+
public int hashCode() {
117+
return Arrays.hashCode(regions);
118+
}
115119
}

0 commit comments

Comments
 (0)