Code Insight: "Generate equals/hashCode" action
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
// NOT_APPLICABLE
|
||||
annotation class A<caret>()
|
||||
@@ -0,0 +1,2 @@
|
||||
// NOT_APPLICABLE
|
||||
data class A<caret>(val n: Int)
|
||||
@@ -0,0 +1,6 @@
|
||||
// NOT_APPLICABLE
|
||||
enum class A {<caret>
|
||||
fun foo() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
class A<T>(val n: T) {<caret>
|
||||
fun foo() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
class A<T>(val n: T) {
|
||||
fun foo() {
|
||||
|
||||
}
|
||||
|
||||
<caret>override fun equals(other: Any?): Boolean{
|
||||
if (this === other) return true
|
||||
if (other?.javaClass != javaClass) return false
|
||||
|
||||
other as A<*>
|
||||
|
||||
if (n != other.n) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int{
|
||||
return n?.hashCode() ?: 0
|
||||
}
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
// USE_IS_CHECK
|
||||
class A<T>(val n: T) {<caret>
|
||||
fun foo() {
|
||||
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
// USE_IS_CHECK
|
||||
class A<T>(val n: T) {
|
||||
fun foo() {
|
||||
|
||||
}
|
||||
|
||||
<caret>override fun equals(other: Any?): Boolean{
|
||||
if (this === other) return true
|
||||
if (other !is A<*>) return false
|
||||
|
||||
if (n != other.n) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int{
|
||||
return n?.hashCode() ?: 0
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
// NOT_APPLICABLE
|
||||
interface A {<caret>
|
||||
fun foo() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
class A(val n: Int, val s: String) {<caret>
|
||||
val f: Float = 1.0f
|
||||
|
||||
fun foo() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
class A(val n: Int, val s: String) {
|
||||
val f: Float = 1.0f
|
||||
|
||||
fun foo() {
|
||||
|
||||
}
|
||||
|
||||
<caret>override fun equals(other: Any?): Boolean{
|
||||
if (this === other) return true
|
||||
if (other?.javaClass != javaClass) return false
|
||||
|
||||
other as A
|
||||
|
||||
if (n != other.n) return false
|
||||
if (s != other.s) return false
|
||||
if (f != other.f) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int{
|
||||
var result = n
|
||||
result += 31 * result + s.hashCode()
|
||||
result += 31 * result + f.hashCode()
|
||||
return result
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
class A(val n: Int?, val s: String) {<caret>
|
||||
val f: Float? = null
|
||||
|
||||
fun foo() {
|
||||
|
||||
}
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
class A(val n: Int?, val s: String) {
|
||||
val f: Float? = null
|
||||
|
||||
fun foo() {
|
||||
|
||||
}
|
||||
|
||||
<caret>override fun equals(other: Any?): Boolean{
|
||||
if (this === other) return true
|
||||
if (other?.javaClass != javaClass) return false
|
||||
|
||||
other as A
|
||||
|
||||
if (n != other.n) return false
|
||||
if (s != other.s) return false
|
||||
if (f != other.f) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int{
|
||||
var result = n ?: 0
|
||||
result += 31 * result + s.hashCode()
|
||||
result += 31 * result + (f?.hashCode() ?: 0)
|
||||
return result
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
open class X {
|
||||
override fun equals(other: Any?) = super.equals(other)
|
||||
override fun hashCode() = super.hashCode()
|
||||
}
|
||||
|
||||
class A(val n: Int, val s: String) : X() {<caret>
|
||||
val f: Float = 1.0f
|
||||
|
||||
fun foo() {
|
||||
|
||||
}
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
open class X {
|
||||
override fun equals(other: Any?) = super.equals(other)
|
||||
override fun hashCode() = super.hashCode()
|
||||
}
|
||||
|
||||
class A(val n: Int, val s: String) : X() {
|
||||
val f: Float = 1.0f
|
||||
|
||||
fun foo() {
|
||||
|
||||
}
|
||||
|
||||
<caret>override fun equals(other: Any?): Boolean{
|
||||
if (this === other) return true
|
||||
if (other?.javaClass != javaClass) return false
|
||||
if (!super.equals(other)) return false
|
||||
|
||||
other as A
|
||||
|
||||
if (n != other.n) return false
|
||||
if (s != other.s) return false
|
||||
if (f != other.f) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int{
|
||||
var result = super.hashCode()
|
||||
result += 31 * result + n
|
||||
result += 31 * result + s.hashCode()
|
||||
result += 31 * result + f.hashCode()
|
||||
return result
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
class A(val result: Int, val s: String) {<caret>
|
||||
fun foo() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
class A(val result: Int, val s: String) {
|
||||
fun foo() {
|
||||
|
||||
}
|
||||
|
||||
<caret>override fun equals(other: Any?): Boolean{
|
||||
if (this === other) return true
|
||||
if (other?.javaClass != javaClass) return false
|
||||
|
||||
other as A
|
||||
|
||||
if (result != other.result) return false
|
||||
if (s != other.s) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int{
|
||||
var result1 = result
|
||||
result1 += 31 * result1 + s.hashCode()
|
||||
return result1
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
// NOT_APPLICABLE
|
||||
class A {<caret>
|
||||
fun foo() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
// FORCED
|
||||
class A {<caret>
|
||||
fun foo() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
// FORCED
|
||||
class A {
|
||||
fun foo() {
|
||||
|
||||
}
|
||||
|
||||
<caret>override fun equals(other: Any?): Boolean{
|
||||
if (this === other) return true
|
||||
if (other?.javaClass != javaClass) return false
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int{
|
||||
return 0
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// FORCED
|
||||
open class X {
|
||||
override fun equals(other: Any?) = super.equals(other)
|
||||
override fun hashCode() = super.hashCode()
|
||||
}
|
||||
|
||||
class A : X() {<caret>
|
||||
fun foo() {
|
||||
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
// FORCED
|
||||
open class X {
|
||||
override fun equals(other: Any?) = super.equals(other)
|
||||
override fun hashCode() = super.hashCode()
|
||||
}
|
||||
|
||||
class A : X() {
|
||||
fun foo() {
|
||||
|
||||
}
|
||||
|
||||
<caret>override fun equals(other: Any?): Boolean{
|
||||
if (this === other) return true
|
||||
if (other?.javaClass != javaClass) return false
|
||||
if (!super.equals(other)) return false
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int{
|
||||
return super.hashCode()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
// NOT_APPLICABLE
|
||||
object A {<caret>
|
||||
fun foo() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
class A(val n: Int) {<caret>
|
||||
fun foo() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
class A(val n: Int) {
|
||||
fun foo() {
|
||||
|
||||
}
|
||||
|
||||
<caret>override fun equals(other: Any?): Boolean{
|
||||
if (this === other) return true
|
||||
if (other?.javaClass != javaClass) return false
|
||||
|
||||
other as A
|
||||
|
||||
if (n != other.n) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int{
|
||||
return n
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
class A(val n: Int?) {<caret>
|
||||
fun foo() {
|
||||
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
class A(val n: Int?) {
|
||||
fun foo() {
|
||||
|
||||
}
|
||||
|
||||
<caret>override fun equals(other: Any?): Boolean{
|
||||
if (this === other) return true
|
||||
if (other?.javaClass != javaClass) return false
|
||||
|
||||
other as A
|
||||
|
||||
if (n != other.n) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int{
|
||||
return n ?: 0
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
// USE_IS_CHECK
|
||||
class A(val n: Int) {<caret>
|
||||
fun foo() {
|
||||
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
// USE_IS_CHECK
|
||||
class A(val n: Int) {
|
||||
fun foo() {
|
||||
|
||||
}
|
||||
|
||||
<caret>override fun equals(other: Any?): Boolean{
|
||||
if (this === other) return true
|
||||
if (other !is A) return false
|
||||
|
||||
if (n != other.n) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int{
|
||||
return n
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
public class X {
|
||||
public boolean equals(Object object) {
|
||||
return super.equals(object);
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return super.hashCode();
|
||||
}
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
class A(val n: Int) : X() {<caret>
|
||||
fun foo() {
|
||||
|
||||
}
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
class A(val n: Int) : X() {
|
||||
fun foo() {
|
||||
|
||||
}
|
||||
|
||||
<caret>override fun equals(other: Any?): Boolean{
|
||||
if (this === other) return true
|
||||
if (other?.javaClass != javaClass) return false
|
||||
if (!super.equals(other)) return false
|
||||
|
||||
other as A
|
||||
|
||||
if (n != other.n) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int{
|
||||
var result = super.hashCode()
|
||||
result += 31 * result + n
|
||||
return result
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
open class X {
|
||||
override fun equals(other: Any?) = super.equals(other)
|
||||
override fun hashCode() = super.hashCode()
|
||||
}
|
||||
|
||||
class A(val n: Int) : X() {<caret>
|
||||
fun foo() {
|
||||
|
||||
}
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
open class X {
|
||||
override fun equals(other: Any?) = super.equals(other)
|
||||
override fun hashCode() = super.hashCode()
|
||||
}
|
||||
|
||||
class A(val n: Int) : X() {
|
||||
fun foo() {
|
||||
|
||||
}
|
||||
|
||||
<caret>override fun equals(other: Any?): Boolean{
|
||||
if (this === other) return true
|
||||
if (other?.javaClass != javaClass) return false
|
||||
if (!super.equals(other)) return false
|
||||
|
||||
other as A
|
||||
|
||||
if (n != other.n) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int{
|
||||
var result = super.hashCode()
|
||||
result += 31 * result + n
|
||||
return result
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user