Files
openide/java/java-tests/testData/codeInsight/generateEquals/afterHashCode.java
Bas Leijdekkers e8d2bff198 Java: generate compact equals when using IntelliJ Default (IDEA-339226)
GitOrigin-RevId: dd90f8e079a2693d74a220ef95aca3223c105fa9
2023-12-05 10:02:17 +00:00

30 lines
752 B
Java

import java.util.Objects;
class Test {
int i;
Test a;
Test b;
double c;
public boolean equals(Object o) {
if (this == o) return true;
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;
}
}