diff --git a/app/src/main/java/com/kunzisoft/keepass/model/EntryInfo.kt b/app/src/main/java/com/kunzisoft/keepass/model/EntryInfo.kt index 1d7aa4da6..9324ea9a8 100644 --- a/app/src/main/java/com/kunzisoft/keepass/model/EntryInfo.kt +++ b/app/src/main/java/com/kunzisoft/keepass/model/EntryInfo.kt @@ -186,6 +186,39 @@ class EntryInfo : NodeInfo { } } + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (other !is EntryInfo) return false + if (!super.equals(other)) return false + + if (id != other.id) return false + if (username != other.username) return false + if (password != other.password) return false + if (url != other.url) return false + if (notes != other.notes) return false + if (customFields != other.customFields) return false + if (attachments != other.attachments) return false + if (otpModel != other.otpModel) return false + if (isTemplate != other.isTemplate) return false + + return true + } + + override fun hashCode(): Int { + var result = super.hashCode() + result = 31 * result + id.hashCode() + result = 31 * result + username.hashCode() + result = 31 * result + password.hashCode() + result = 31 * result + url.hashCode() + result = 31 * result + notes.hashCode() + result = 31 * result + customFields.hashCode() + result = 31 * result + attachments.hashCode() + result = 31 * result + (otpModel?.hashCode() ?: 0) + result = 31 * result + isTemplate.hashCode() + return result + } + + companion object { const val WEB_DOMAIN_FIELD_NAME = "URL" diff --git a/app/src/main/java/com/kunzisoft/keepass/model/GroupInfo.kt b/app/src/main/java/com/kunzisoft/keepass/model/GroupInfo.kt index 491ed3838..f66072fc2 100644 --- a/app/src/main/java/com/kunzisoft/keepass/model/GroupInfo.kt +++ b/app/src/main/java/com/kunzisoft/keepass/model/GroupInfo.kt @@ -24,6 +24,22 @@ class GroupInfo : NodeInfo { parcel.writeString(notes) } + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (other !is GroupInfo) return false + if (!super.equals(other)) return false + + if (notes != other.notes) return false + + return true + } + + override fun hashCode(): Int { + var result = super.hashCode() + result = 31 * result + (notes?.hashCode() ?: 0) + return result + } + companion object CREATOR : Parcelable.Creator { override fun createFromParcel(parcel: Parcel): GroupInfo { return GroupInfo(parcel) diff --git a/app/src/main/java/com/kunzisoft/keepass/model/NodeInfo.kt b/app/src/main/java/com/kunzisoft/keepass/model/NodeInfo.kt index 9c0fa4d62..aad2fd752 100644 --- a/app/src/main/java/com/kunzisoft/keepass/model/NodeInfo.kt +++ b/app/src/main/java/com/kunzisoft/keepass/model/NodeInfo.kt @@ -36,6 +36,30 @@ open class NodeInfo() : Parcelable { return 0 } + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (other !is NodeInfo) return false + + if (title != other.title) return false + if (icon != other.icon) return false + if (creationTime != other.creationTime) return false + if (lastModificationTime != other.lastModificationTime) return false + if (expires != other.expires) return false + if (expiryTime != other.expiryTime) return false + + return true + } + + override fun hashCode(): Int { + var result = title.hashCode() + result = 31 * result + icon.hashCode() + result = 31 * result + creationTime.hashCode() + result = 31 * result + lastModificationTime.hashCode() + result = 31 * result + expires.hashCode() + result = 31 * result + expiryTime.hashCode() + return result + } + companion object CREATOR : Parcelable.Creator { override fun createFromParcel(parcel: Parcel): NodeInfo { return NodeInfo(parcel)