diff --git a/persistence/json/BankingPersistenceJson/src/main/kotlin/net/dankito/banking/persistence/model/AccountTransactionEntity.kt b/persistence/json/BankingPersistenceJson/src/main/kotlin/net/dankito/banking/persistence/model/AccountTransactionEntity.kt index df72e5bb..058cc61e 100644 --- a/persistence/json/BankingPersistenceJson/src/main/kotlin/net/dankito/banking/persistence/model/AccountTransactionEntity.kt +++ b/persistence/json/BankingPersistenceJson/src/main/kotlin/net/dankito/banking/persistence/model/AccountTransactionEntity.kt @@ -61,4 +61,13 @@ open class AccountTransactionEntity( null, null, null, null, null, null, null, null, null, null, null, null, null, null, "", "", null, null, "", null) + + override fun equals(other: Any?): Boolean { + return doesEqual(other) + } + + override fun hashCode(): Int { + return calculateHashCode() + } + } \ No newline at end of file diff --git a/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/AccountTransaction.kt b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/AccountTransaction.kt index 0e69c2fd..9fb41cc0 100644 --- a/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/AccountTransaction.kt +++ b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/AccountTransaction.kt @@ -68,35 +68,11 @@ open class AccountTransaction( override fun equals(other: Any?): Boolean { - if (this === other) return true - if (other !is AccountTransaction) return false - - if (bankAccount != other.bankAccount) return false - if (amount != other.amount) return false - if (currency != other.currency) return false - if (unparsedUsage != other.unparsedUsage) return false - if (bookingDate != other.bookingDate) return false - if (otherPartyName != other.otherPartyName) return false - if (otherPartyBankCode != other.otherPartyBankCode) return false - if (otherPartyAccountId != other.otherPartyAccountId) return false - if (bookingText != other.bookingText) return false - if (valueDate != other.valueDate) return false - - return true + return doesEqual(other) } override fun hashCode(): Int { - var result = bankAccount.hashCode() - result = 31 * result + amount.hashCode() - result = 31 * result + currency.hashCode() - result = 31 * result + unparsedUsage.hashCode() - result = 31 * result + bookingDate.hashCode() - result = 31 * result + (otherPartyName?.hashCode() ?: 0) - result = 31 * result + (otherPartyBankCode?.hashCode() ?: 0) - result = 31 * result + (otherPartyAccountId?.hashCode() ?: 0) - result = 31 * result + (bookingText?.hashCode() ?: 0) - result = 31 * result + valueDate.hashCode() - return result + return calculateHashCode() } diff --git a/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/IAccountTransaction.kt b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/IAccountTransaction.kt index 07262874..a2594e52 100644 --- a/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/IAccountTransaction.kt +++ b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/IAccountTransaction.kt @@ -72,5 +72,39 @@ interface IAccountTransaction { return " ${IdDateFormat.format(bookingDate)} ${IdDateFormat.format(valueDate)} $amount $currency $unparsedUsage $otherPartyName $otherPartyBankCode $otherPartyAccountId" } } + + + + fun doesEqual(other: Any?): Boolean { + if (this === other) return true + if (other !is IAccountTransaction) return false + + if (bankAccount != other.bankAccount) return false + if (amount != other.amount) return false + if (currency != other.currency) return false + if (unparsedUsage != other.unparsedUsage) return false + if (bookingDate != other.bookingDate) return false + if (otherPartyName != other.otherPartyName) return false + if (otherPartyBankCode != other.otherPartyBankCode) return false + if (otherPartyAccountId != other.otherPartyAccountId) return false + if (bookingText != other.bookingText) return false + if (valueDate != other.valueDate) return false + + return true + } + + fun calculateHashCode(): Int { + var result = bankAccount.hashCode() + result = 31 * result + amount.hashCode() + result = 31 * result + currency.hashCode() + result = 31 * result + unparsedUsage.hashCode() + result = 31 * result + bookingDate.hashCode() + result = 31 * result + (otherPartyName?.hashCode() ?: 0) + result = 31 * result + (otherPartyBankCode?.hashCode() ?: 0) + result = 31 * result + (otherPartyAccountId?.hashCode() ?: 0) + result = 31 * result + (bookingText?.hashCode() ?: 0) + result = 31 * result + valueDate.hashCode() + return result + } } \ No newline at end of file