fix: implement hashcode and equals to make pollers unique in concurrent hash map

This commit is contained in:
0x330a
2023-09-13 18:39:16 +10:00
parent 82e3516a60
commit e8ade014ae
2 changed files with 27 additions and 4 deletions

View File

@@ -22,4 +22,25 @@ class SessionId {
}
fun hexString() = prefix?.value + publicKey
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false
other as SessionId
if (prefix != other.prefix) return false
if (publicKey != other.publicKey) return false
return true
}
override fun hashCode(): Int {
var result = prefix?.hashCode() ?: 0
result = 31 * result + publicKey.hashCode()
return result
}
}