From bab012a9ebda5440601c30fe757759b1597919b5 Mon Sep 17 00:00:00 2001 From: dankito Date: Sat, 8 Aug 2020 19:24:18 +0200 Subject: [PATCH] Implemented equals() and hashCode() --- .../banking/ui/model/tan/TanProcedure.kt | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/tan/TanProcedure.kt b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/tan/TanProcedure.kt index d213db31..123e4d27 100644 --- a/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/tan/TanProcedure.kt +++ b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/tan/TanProcedure.kt @@ -11,6 +11,25 @@ open class TanProcedure( internal constructor() : this("", TanProcedureType.EnterTan, "") // for object deserializers + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (other !is TanProcedure) return false + + if (displayName != other.displayName) return false + if (type != other.type) return false + if (bankInternalProcedureCode != other.bankInternalProcedureCode) return false + + return true + } + + override fun hashCode(): Int { + var result = displayName.hashCode() + result = 31 * result + type.hashCode() + result = 31 * result + bankInternalProcedureCode.hashCode() + return result + } + + override fun toString(): String { return "$displayName ($type, ${bankInternalProcedureCode})" }