From c0af13dcab31861a6fe3d5ba299562bc594f4c1c Mon Sep 17 00:00:00 2001 From: Alex Plate Date: Fri, 8 May 2020 18:03:36 +0300 Subject: [PATCH] [Workspace Model] ConnectionId is no more dataclass GitOrigin-RevId: b713d1ed90043e9c4a6c497b5f98503a131d1db9 --- .../src/pstorage/RefsTable.kt | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/platform/workspaceModel-core/src/pstorage/RefsTable.kt b/platform/workspaceModel-core/src/pstorage/RefsTable.kt index a0ff858480d8..02461c8f75f6 100644 --- a/platform/workspaceModel-core/src/pstorage/RefsTable.kt +++ b/platform/workspaceModel-core/src/pstorage/RefsTable.kt @@ -9,7 +9,7 @@ import com.intellij.workspace.api.pstorage.containers.* import pstorage.containers.LinkedBidirectionalMap import kotlin.reflect.KClass -internal data class ConnectionId private constructor( +internal class ConnectionId private constructor( val parentClass: KClass, val childClass: KClass, val connectionType: ConnectionType, @@ -23,6 +23,30 @@ internal data class ConnectionId private co ABSTRACT_ONE_TO_ONE } + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + + other as ConnectionId<*, *> + + if (parentClass.java != other.parentClass.java) return false + if (childClass.java != other.childClass.java) return false + if (connectionType != other.connectionType) return false + if (isParentNullable != other.isParentNullable) return false + if (isChildNullable != other.isChildNullable) return false + + return true + } + + override fun hashCode(): Int { + var result = parentClass.java.hashCode() + result = 31 * result + childClass.java.hashCode() + result = 31 * result + connectionType.hashCode() + result = 31 * result + isParentNullable.hashCode() + result = 31 * result + isChildNullable.hashCode() + return result + } + companion object { /** This function should be [@Synchronized] because interner is not thread-save */ @Suppress("UNCHECKED_CAST")