Generate equals and hashCode for BotAccount

This commit is contained in:
Him188 2020-02-15 13:10:12 +08:00
parent 45d5131e32
commit ba212d2b7a

View File

@ -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
}
}
/**