Files
openide/java/java-tests/testData/codeInsight/generateEquals/afterHashCode.java
Bas Leijdekkers 7fbe663b37 Java: don't add instance check when generating equals() (IDEA-357686)
GitOrigin-RevId: 21a0555c2fe6be705fe4d510c8d8d08238af4585
2024-09-25 21:53:25 +00:00

29 lines
716 B
Java

import java.util.Objects;
class Test {
int i;
Test a;
Test b;
double c;
public boolean equals(Object o) {
if (o == null || getClass() != o.getClass()) return false;
final Test test = (Test) o;
return i == test.i &&
Double.compare(c, test.c) == 0 &&
a.equals(test.a) &&
Objects.equals(b, test.b);
}
public int hashCode() {
int result;
long temp;
result = i;
result = 31 * result + a.hashCode();
result = 31 * result + Objects.hashCode(b);
temp = Double.doubleToLongBits(c);
result = 31 * result + (int) (temp ^ (temp >>> 32));
return result;
}
}