mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-01 13:12:52 +08:00
Generate equals
and hashCode
for BotAccount
This commit is contained in:
parent
45d5131e32
commit
ba212d2b7a
@ -26,6 +26,24 @@ data class BotAccount(
|
||||
val passwordMd5: ByteArray // md5
|
||||
) {
|
||||
constructor(id: Long, passwordPlainText: String) : this(id, md5(passwordPlainText.toByteArray()))
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (other == null || this::class != other::class) return false
|
||||
|
||||
other as BotAccount
|
||||
|
||||
if (id != other.id) return false
|
||||
if (!passwordMd5.contentEquals(other.passwordMd5)) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
var result = id.hashCode()
|
||||
result = 31 * result + passwordMd5.contentHashCode()
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user