We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I wrote the following, wrong class; pojo tester claims it's well implemented.
public class TestClass { @Nullable private Double testField; public TestClass(@Nullable Double testField) { this.testField = testField; } @Nullable public Double getTestField() { return testField; } public void setTestField(@Nullable Double testField) { this.testField = testField; } @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } TestClass that = (TestClass)o; if (!(testField == null && that.testField == null) || (testField != null && that.testField != null && Double.compare(testField, that.testField) != 0)) { return false; } return true; } @Override public int hashCode() { return Objects.hash(testField); } @Override public String toString() { final StringBuilder sb = new StringBuilder("TestClass {"); sb.append("testField=").append(testField); sb.append('}'); return sb.toString(); } }
However, this simple test is enough to show the equals method is wrong:
TestClass testClass = new TestClass(2d); TestClass testClass2 = new TestClass(2d); assertEquals(testClass, testClass2);
The text was updated successfully, but these errors were encountered:
Fix equals tester for different instances
5c69d1d
fixes sta-szek#248
Successfully merging a pull request may close this issue.
I wrote the following, wrong class; pojo tester claims it's well implemented.
However, this simple test is enough to show the equals method is wrong:
The text was updated successfully, but these errors were encountered: