Files
openide/java/java-tests/testData/codeInsight/generateEquals/afterPrimitiveFieldsJava8.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

34 lines
945 B
Java

public class X {
private long l = 1l;
private boolean b = true;
private byte v = 1;
private short s = 1;
private int i = 1;
private float f = 1.0f;
private double d = 1.0;
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
final X x = (X) o;
return l == x.l &&
b == x.b &&
v == x.v &&
s == x.s &&
i == x.i &&
Float.compare(f, x.f) == 0 &&
Double.compare(d, x.d) == 0;
}
public int hashCode() {
int result = Long.hashCode(l);
result = 31 * result + Boolean.hashCode(b);
result = 31 * result + v;
result = 31 * result + s;
result = 31 * result + i;
result = 31 * result + Float.hashCode(f);
result = 31 * result + Double.hashCode(d);
return result;
}
}