mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-26 15:27:45 +07:00
generate equals/hashCode: use velocity templates
This commit is contained in:
@@ -21,7 +21,7 @@ class Test {
|
||||
|
||||
public int hashCode() {
|
||||
int result = myOs != null ? Arrays.hashCode(myOs) : 0;
|
||||
result = 31 * result + (myIIs != null ? // Probably incorrect - hashCode for high dimension arrays with Arrays.hashCode
|
||||
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;
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
import java.util.Arrays;
|
||||
|
||||
class A {
|
||||
Object[] a1;
|
||||
Object[][] a2;
|
||||
String[] a3;
|
||||
String[][] a4;
|
||||
int[] a5;
|
||||
int[][] a6;
|
||||
|
||||
byte a7;
|
||||
short a8;
|
||||
int a9;
|
||||
long a10;
|
||||
float a11;
|
||||
double a12;
|
||||
|
||||
Object a13;
|
||||
String a14;
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
final A a = (A) o;
|
||||
|
||||
if (a10 != a.a10) return false;
|
||||
if (Float.compare(a.a11, a11) != 0) return false;
|
||||
if (Double.compare(a.a12, a12) != 0) return false;
|
||||
if (a7 != a.a7) return false;
|
||||
if (a8 != a.a8) return false;
|
||||
if (a9 != a.a9) return false;
|
||||
// Probably incorrect - comparing Object[] arrays with Arrays.equals
|
||||
if (!Arrays.equals(a1, a.a1)) return false;
|
||||
if (a13 != null ? !a13.equals(a.a13) : a.a13 != null) return false;
|
||||
if (a14 != null ? !a14.equals(a.a14) : a.a14 != null) return false;
|
||||
if (!Arrays.deepEquals(a2, a.a2)) return false;
|
||||
// Probably incorrect - comparing Object[] arrays with Arrays.equals
|
||||
if (!Arrays.equals(a3, a.a3)) return false;
|
||||
if (!Arrays.deepEquals(a4, a.a4)) return false;
|
||||
if (!Arrays.equals(a5, a.a5)) return false;
|
||||
if (!Arrays.deepEquals(a6, a.a6)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result;
|
||||
long temp;
|
||||
result = a1 != null ? Arrays.hashCode(a1) : 0;
|
||||
result = 31 * result + (a2 != null ? // Probably incorrect - hashCode for high dimension arrays with Arrays.hashCode
|
||||
Arrays.hashCode(a2) : 0);
|
||||
result = 31 * result + (a3 != null ? Arrays.hashCode(a3) : 0);
|
||||
result = 31 * result + (a4 != null ? // Probably incorrect - hashCode for high dimension arrays with Arrays.hashCode
|
||||
Arrays.hashCode(a4) : 0);
|
||||
result = 31 * result + (a5 != null ? Arrays.hashCode(a5) : 0);
|
||||
result = 31 * result + (a6 != null ? // Probably incorrect - hashCode for high dimension arrays with Arrays.hashCode
|
||||
Arrays.hashCode(a6) : 0);
|
||||
result = 31 * result + (int) a7;
|
||||
result = 31 * result + (int) a8;
|
||||
result = 31 * result + a9;
|
||||
result = 31 * result + (int) (a10 ^ (a10 >>> 32));
|
||||
result = 31 * result + (a11 != +0.0f ? Float.floatToIntBits(a11) : 0);
|
||||
temp = Double.doubleToLongBits(a12);
|
||||
result = 31 * result + (int) (temp ^ (temp >>> 32));
|
||||
result = 31 * result + (a13 != null ? a13.hashCode() : 0);
|
||||
result = 31 * result + (a14 != null ? a14.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
import java.util.Arrays;
|
||||
|
||||
class A {
|
||||
Object[] a1;
|
||||
Object[][] a2;
|
||||
String[] a3;
|
||||
String[][] a4;
|
||||
int[] a5;
|
||||
int[][] a6;
|
||||
|
||||
byte a7;
|
||||
short a8;
|
||||
int a9;
|
||||
long a10;
|
||||
float a11;
|
||||
double a12;
|
||||
|
||||
Object a13;
|
||||
String a14;
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
final A a = (A) o;
|
||||
|
||||
if (a10 != a.a10) return false;
|
||||
if (Float.compare(a.a11, a11) != 0) return false;
|
||||
if (Double.compare(a.a12, a12) != 0) return false;
|
||||
if (a7 != a.a7) return false;
|
||||
if (a8 != a.a8) return false;
|
||||
if (a9 != a.a9) return false;
|
||||
// Probably incorrect - comparing Object[] arrays with Arrays.equals
|
||||
if (!Arrays.equals(a1, a.a1)) return false;
|
||||
if (!a13.equals(a.a13)) return false;
|
||||
if (!a14.equals(a.a14)) return false;
|
||||
if (!Arrays.deepEquals(a2, a.a2)) return false;
|
||||
// Probably incorrect - comparing Object[] arrays with Arrays.equals
|
||||
if (!Arrays.equals(a3, a.a3)) return false;
|
||||
if (!Arrays.deepEquals(a4, a.a4)) return false;
|
||||
if (!Arrays.equals(a5, a.a5)) return false;
|
||||
if (!Arrays.deepEquals(a6, a.a6)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result;
|
||||
long temp;
|
||||
result = Arrays.hashCode(a1);
|
||||
result = 31 * result + // Probably incorrect - hashCode for high dimension arrays with Arrays.hashCode
|
||||
Arrays.hashCode(a2);
|
||||
result = 31 * result + Arrays.hashCode(a3);
|
||||
result = 31 * result + // Probably incorrect - hashCode for high dimension arrays with Arrays.hashCode
|
||||
Arrays.hashCode(a4);
|
||||
result = 31 * result + Arrays.hashCode(a5);
|
||||
result = 31 * result + // Probably incorrect - hashCode for high dimension arrays with Arrays.hashCode
|
||||
Arrays.hashCode(a6);
|
||||
result = 31 * result + (int) a7;
|
||||
result = 31 * result + (int) a8;
|
||||
result = 31 * result + a9;
|
||||
result = 31 * result + (int) (a10 ^ (a10 >>> 32));
|
||||
result = 31 * result + (a11 != +0.0f ? Float.floatToIntBits(a11) : 0);
|
||||
temp = Double.doubleToLongBits(a12);
|
||||
result = 31 * result + (int) (temp ^ (temp >>> 32));
|
||||
result = 31 * result + a13.hashCode();
|
||||
result = 31 * result + a14.hashCode();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
import java.util.Arrays;
|
||||
|
||||
class A {
|
||||
Object[] a1;
|
||||
Object[][] a2;
|
||||
String[] a3;
|
||||
String[][] a4;
|
||||
int[] a5;
|
||||
int[][] a6;
|
||||
|
||||
byte a7;
|
||||
short a8;
|
||||
int a9;
|
||||
long a10;
|
||||
float a11;
|
||||
|
||||
Object a13;
|
||||
String a14;
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
final A a = (A) o;
|
||||
|
||||
if (a10 != a.a10) return false;
|
||||
if (Float.compare(a.a11, a11) != 0) return false;
|
||||
if (a7 != a.a7) return false;
|
||||
if (a8 != a.a8) return false;
|
||||
if (a9 != a.a9) return false;
|
||||
// Probably incorrect - comparing Object[] arrays with Arrays.equals
|
||||
if (!Arrays.equals(a1, a.a1)) return false;
|
||||
if (!a13.equals(a.a13)) return false;
|
||||
if (!a14.equals(a.a14)) return false;
|
||||
if (!Arrays.deepEquals(a2, a.a2)) return false;
|
||||
// Probably incorrect - comparing Object[] arrays with Arrays.equals
|
||||
if (!Arrays.equals(a3, a.a3)) return false;
|
||||
if (!Arrays.deepEquals(a4, a.a4)) return false;
|
||||
if (!Arrays.equals(a5, a.a5)) return false;
|
||||
if (!Arrays.deepEquals(a6, a.a6)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = Arrays.hashCode(a1);
|
||||
result = 31 * result + // Probably incorrect - hashCode for high dimension arrays with Arrays.hashCode
|
||||
Arrays.hashCode(a2);
|
||||
result = 31 * result + Arrays.hashCode(a3);
|
||||
result = 31 * result + // Probably incorrect - hashCode for high dimension arrays with Arrays.hashCode
|
||||
Arrays.hashCode(a4);
|
||||
result = 31 * result + Arrays.hashCode(a5);
|
||||
result = 31 * result + // Probably incorrect - hashCode for high dimension arrays with Arrays.hashCode
|
||||
Arrays.hashCode(a6);
|
||||
result = 31 * result + (int) a7;
|
||||
result = 31 * result + (int) a8;
|
||||
result = 31 * result + a9;
|
||||
result = 31 * result + (int) (a10 ^ (a10 >>> 32));
|
||||
result = 31 * result + (a11 != +0.0f ? Float.floatToIntBits(a11) : 0);
|
||||
result = 31 * result + a13.hashCode();
|
||||
result = 31 * result + a14.hashCode();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
+85
@@ -0,0 +1,85 @@
|
||||
import java.util.Arrays;
|
||||
|
||||
class B {
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return obj != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return super.hashCode();
|
||||
}
|
||||
}
|
||||
class A extends B {
|
||||
Object[] a1;
|
||||
Object[][] a2;
|
||||
String[] a3;
|
||||
String[][] a4;
|
||||
int[] a5;
|
||||
int[][] a6;
|
||||
|
||||
byte a7;
|
||||
short a8;
|
||||
int a9;
|
||||
long a10;
|
||||
float a11;
|
||||
double a12;
|
||||
|
||||
Object a13;
|
||||
String a14;
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
if (!super.equals(o)) return false;
|
||||
|
||||
final A a = (A) o;
|
||||
|
||||
if (a10 != a.a10) return false;
|
||||
if (Float.compare(a.a11, a11) != 0) return false;
|
||||
if (Double.compare(a.a12, a12) != 0) return false;
|
||||
if (a7 != a.a7) return false;
|
||||
if (a8 != a.a8) return false;
|
||||
if (a9 != a.a9) return false;
|
||||
// Probably incorrect - comparing Object[] arrays with Arrays.equals
|
||||
if (!Arrays.equals(a1, a.a1)) return false;
|
||||
if (!a13.equals(a.a13)) return false;
|
||||
if (!a14.equals(a.a14)) return false;
|
||||
if (!Arrays.deepEquals(a2, a.a2)) return false;
|
||||
// Probably incorrect - comparing Object[] arrays with Arrays.equals
|
||||
if (!Arrays.equals(a3, a.a3)) return false;
|
||||
if (!Arrays.deepEquals(a4, a.a4)) return false;
|
||||
if (!Arrays.equals(a5, a.a5)) return false;
|
||||
if (!Arrays.deepEquals(a6, a.a6)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = super.hashCode();
|
||||
long temp;
|
||||
result = 31 * result + Arrays.hashCode(a1);
|
||||
result = 31 * result + // Probably incorrect - hashCode for high dimension arrays with Arrays.hashCode
|
||||
Arrays.hashCode(a2);
|
||||
result = 31 * result + Arrays.hashCode(a3);
|
||||
result = 31 * result + // Probably incorrect - hashCode for high dimension arrays with Arrays.hashCode
|
||||
Arrays.hashCode(a4);
|
||||
result = 31 * result + Arrays.hashCode(a5);
|
||||
result = 31 * result + // Probably incorrect - hashCode for high dimension arrays with Arrays.hashCode
|
||||
Arrays.hashCode(a6);
|
||||
result = 31 * result + (int) a7;
|
||||
result = 31 * result + (int) a8;
|
||||
result = 31 * result + a9;
|
||||
result = 31 * result + (int) (a10 ^ (a10 >>> 32));
|
||||
result = 31 * result + (a11 != +0.0f ? Float.floatToIntBits(a11) : 0);
|
||||
temp = Double.doubleToLongBits(a12);
|
||||
result = 31 * result + (int) (temp ^ (temp >>> 32));
|
||||
result = 31 * result + a13.hashCode();
|
||||
result = 31 * result + a14.hashCode();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
import java.util.Arrays;
|
||||
|
||||
class A {
|
||||
Object[] a1;
|
||||
Object[][] a2;
|
||||
String[] a3;
|
||||
String[][] a4;
|
||||
int[] a5;
|
||||
int[][] a6;
|
||||
|
||||
byte a7;
|
||||
short a8;
|
||||
int a9;
|
||||
long a10;
|
||||
float a11;
|
||||
double temp;
|
||||
|
||||
Object result;
|
||||
String a14;
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
final A a = (A) o;
|
||||
|
||||
if (a10 != a.a10) return false;
|
||||
if (Float.compare(a.a11, a11) != 0) return false;
|
||||
if (a7 != a.a7) return false;
|
||||
if (a8 != a.a8) return false;
|
||||
if (a9 != a.a9) return false;
|
||||
if (Double.compare(a.temp, temp) != 0) return false;
|
||||
// Probably incorrect - comparing Object[] arrays with Arrays.equals
|
||||
if (!Arrays.equals(a1, a.a1)) return false;
|
||||
if (!a14.equals(a.a14)) return false;
|
||||
if (!Arrays.deepEquals(a2, a.a2)) return false;
|
||||
// Probably incorrect - comparing Object[] arrays with Arrays.equals
|
||||
if (!Arrays.equals(a3, a.a3)) return false;
|
||||
if (!Arrays.deepEquals(a4, a.a4)) return false;
|
||||
if (!Arrays.equals(a5, a.a5)) return false;
|
||||
if (!Arrays.deepEquals(a6, a.a6)) return false;
|
||||
if (!result.equals(a.result)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result1;
|
||||
long temp1;
|
||||
result1 = Arrays.hashCode(a1);
|
||||
result1 = 31 * result1 + // Probably incorrect - hashCode for high dimension arrays with Arrays.hashCode
|
||||
Arrays.hashCode(a2);
|
||||
result1 = 31 * result1 + Arrays.hashCode(a3);
|
||||
result1 = 31 * result1 + // Probably incorrect - hashCode for high dimension arrays with Arrays.hashCode
|
||||
Arrays.hashCode(a4);
|
||||
result1 = 31 * result1 + Arrays.hashCode(a5);
|
||||
result1 = 31 * result1 + // Probably incorrect - hashCode for high dimension arrays with Arrays.hashCode
|
||||
Arrays.hashCode(a6);
|
||||
result1 = 31 * result1 + (int) a7;
|
||||
result1 = 31 * result1 + (int) a8;
|
||||
result1 = 31 * result1 + a9;
|
||||
result1 = 31 * result1 + (int) (a10 ^ (a10 >>> 32));
|
||||
result1 = 31 * result1 + (a11 != +0.0f ? Float.floatToIntBits(a11) : 0);
|
||||
temp1 = Double.doubleToLongBits(temp);
|
||||
result1 = 31 * result1 + (int) (temp1 ^ (temp1 >>> 32));
|
||||
result1 = 31 * result1 + result.hashCode();
|
||||
result1 = 31 * result1 + a14.hashCode();
|
||||
return result1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
|
||||
class A {
|
||||
Object[] a1;
|
||||
Object[][] a2;
|
||||
String[] a3;
|
||||
String[][] a4;
|
||||
int[] a5;
|
||||
int[][] a6;
|
||||
|
||||
byte a7;
|
||||
short a8;
|
||||
int a9;
|
||||
long a10;
|
||||
float a11;
|
||||
double a12;
|
||||
|
||||
Object a13;
|
||||
String a14;
|
||||
|
||||
<caret>
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
|
||||
class A {
|
||||
Object[] a1;
|
||||
Object[][] a2;
|
||||
String[] a3;
|
||||
String[][] a4;
|
||||
int[] a5;
|
||||
int[][] a6;
|
||||
|
||||
byte a7;
|
||||
short a8;
|
||||
int a9;
|
||||
long a10;
|
||||
float a11;
|
||||
double a12;
|
||||
|
||||
Object a13;
|
||||
String a14;
|
||||
|
||||
<caret>
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
|
||||
class A {
|
||||
Object[] a1;
|
||||
Object[][] a2;
|
||||
String[] a3;
|
||||
String[][] a4;
|
||||
int[] a5;
|
||||
int[][] a6;
|
||||
|
||||
byte a7;
|
||||
short a8;
|
||||
int a9;
|
||||
long a10;
|
||||
float a11;
|
||||
|
||||
Object a13;
|
||||
String a14;
|
||||
|
||||
<caret>
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
class B {
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return obj != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return super.hashCode();
|
||||
}
|
||||
}
|
||||
class A extends B {
|
||||
Object[] a1;
|
||||
Object[][] a2;
|
||||
String[] a3;
|
||||
String[][] a4;
|
||||
int[] a5;
|
||||
int[][] a6;
|
||||
|
||||
byte a7;
|
||||
short a8;
|
||||
int a9;
|
||||
long a10;
|
||||
float a11;
|
||||
double a12;
|
||||
|
||||
Object a13;
|
||||
String a14;
|
||||
|
||||
<caret>
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
|
||||
class A {
|
||||
Object[] a1;
|
||||
Object[][] a2;
|
||||
String[] a3;
|
||||
String[][] a4;
|
||||
int[] a5;
|
||||
int[][] a6;
|
||||
|
||||
byte a7;
|
||||
short a8;
|
||||
int a9;
|
||||
long a10;
|
||||
float a11;
|
||||
double temp;
|
||||
|
||||
Object result;
|
||||
String a14;
|
||||
|
||||
<caret>
|
||||
}
|
||||
Reference in New Issue
Block a user