From 00927bb7001abefe87e23e4f8da081a66bd91ca6 Mon Sep 17 00:00:00 2001 From: Koen <koen@pop-os.localdomain> Date: Fri, 16 Feb 2024 14:07:17 +0100 Subject: [PATCH] Added missing equality. --- .../java/com/futo/polycentric/core/Models.kt | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/app/src/main/java/com/futo/polycentric/core/Models.kt b/app/src/main/java/com/futo/polycentric/core/Models.kt index f273a21..b1c40aa 100644 --- a/app/src/main/java/com/futo/polycentric/core/Models.kt +++ b/app/src/main/java/com/futo/polycentric/core/Models.kt @@ -474,6 +474,22 @@ class ProcessSecret(val system: KeyPair, val process: Process) { return ProcessHandle(this, system.publicKey) } + override fun hashCode(): Int { + return combineHashCodes(listOf(system.hashCode(), process.hashCode())) + } + + override fun toString(): String { + return "(system: $system, process: $process)" + } + + override fun equals(other: Any?): Boolean { + if (other !is ProcessSecret) { + return false + } + + return system == other.system && process == other.process + } + companion object { fun fromProto(proto: Protocol.StorageTypeProcessSecret): ProcessSecret { if (!proto.hasSystem()) { @@ -590,6 +606,18 @@ data class KeyPair(val privateKey: PrivateKey, val publicKey: PublicKey) { return "(privateKey: $privateKey, publicKey: $publicKey)" } + override fun hashCode(): Int { + return combineHashCodes(listOf(privateKey.hashCode(), publicKey.hashCode())) + } + + override fun equals(other: Any?): Boolean { + if (other !is KeyPair) { + return false + } + + return privateKey == other.privateKey && publicKey == other.publicKey + } + companion object { fun fromProto(proto: Protocol.KeyPair): KeyPair { return KeyPair( -- GitLab