From ba35eb76c26ad45d5a71fdc7d7a683ed10b02af7 Mon Sep 17 00:00:00 2001 From: Mikhail Yasnov Date: Thu, 15 Jul 2021 11:28:35 +0300 Subject: [PATCH] Override equals and hashCode for DeviceEntity --- .../auth/core/device/models/DeviceEntity.kt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/auth-core/src/main/kotlin/ru/touchin/auth/core/device/models/DeviceEntity.kt b/auth-core/src/main/kotlin/ru/touchin/auth/core/device/models/DeviceEntity.kt index 09c6d06..654939b 100644 --- a/auth-core/src/main/kotlin/ru/touchin/auth/core/device/models/DeviceEntity.kt +++ b/auth-core/src/main/kotlin/ru/touchin/auth/core/device/models/DeviceEntity.kt @@ -25,6 +25,20 @@ class DeviceEntity: AuditableUuidIdEntity() { ) lateinit var users: Set + override fun equals(other: Any?): Boolean { + if (other == null || this.javaClass != other.javaClass) { + return false + } + + other as DeviceEntity + + return this.id == other.id + } + + override fun hashCode(): Int { + return this.id.hashCode() + } + companion object { fun create(platform: DevicePlatform): DeviceEntity { return DeviceEntity().apply {