generate equals/hashCode: support deep arrays equals for java > 1.5 (IDEA-131533)

This commit is contained in:
Anna Kozlova
2014-12-24 20:26:36 +01:00
parent 6f12108208
commit bb51fb1c63
3 changed files with 48 additions and 31 deletions
@@ -11,7 +11,7 @@ class Test {
final Test test = (Test) o;
// Compare nested arrays - values of myIIs here
if (!Arrays.deepEquals(myIIs, test.myIIs)) return false;
if (!Arrays.equals(myIs, test.myIs)) return false;
// Probably incorrect - comparing Object[] arrays with Arrays.equals
if (!Arrays.equals(myOs, test.myOs)) return false;
@@ -21,7 +21,8 @@ class Test {
public int hashCode() {
int result = myOs != null ? Arrays.hashCode(myOs) : 0;
result = 31 * result + (myIIs != null ? Arrays.hashCode(myIIs) : 0);
result = 31 * result + (myIIs != null ? // Probably incorrect - hashCode for high dimension arrays with Arrays.hashCode
Arrays.hashCode(myIIs) : 0);
result = 31 * result + (myIs != null ? Arrays.hashCode(myIs) : 0);
return result;
}