From 9f1343c02ed2f40a1ad2b47141aa2a489c3cb4bd Mon Sep 17 00:00:00 2001 From: Him188 Date: Mon, 5 Jul 2021 15:27:53 +0800 Subject: [PATCH] Generate `equals`, `hashCode` and `toString` for `AnnouncementParameters` abd `AnnouncementImage` --- .../contact/announcement/AnnouncementImage.kt | 24 +++++++++++++++ .../announcement/AnnouncementParameters.kt | 30 +++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/mirai-core-api/src/commonMain/kotlin/contact/announcement/AnnouncementImage.kt b/mirai-core-api/src/commonMain/kotlin/contact/announcement/AnnouncementImage.kt index 96560988f..94b36a1dd 100644 --- a/mirai-core-api/src/commonMain/kotlin/contact/announcement/AnnouncementImage.kt +++ b/mirai-core-api/src/commonMain/kotlin/contact/announcement/AnnouncementImage.kt @@ -30,4 +30,28 @@ public class AnnouncementImage @MiraiInternalApi public constructor( public companion object { public const val SERIAL_NAME: String = "AnnouncementImage" } + + override fun toString(): String { + return "AnnouncementImage(height='$height', width='$width', id='$id')" + } + + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + + other as AnnouncementImage + + if (height != other.height) return false + if (width != other.width) return false + if (id != other.id) return false + + return true + } + + override fun hashCode(): Int { + var result = height.hashCode() + result = 31 * result + width.hashCode() + result = 31 * result + id.hashCode() + return result + } } \ No newline at end of file diff --git a/mirai-core-api/src/commonMain/kotlin/contact/announcement/AnnouncementParameters.kt b/mirai-core-api/src/commonMain/kotlin/contact/announcement/AnnouncementParameters.kt index c85460c39..08737681a 100644 --- a/mirai-core-api/src/commonMain/kotlin/contact/announcement/AnnouncementParameters.kt +++ b/mirai-core-api/src/commonMain/kotlin/contact/announcement/AnnouncementParameters.kt @@ -76,4 +76,34 @@ public class AnnouncementParameters internal constructor( @get:JvmName("getDefault") public val DEFAULT: AnnouncementParameters = AnnouncementParameters() } + + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + + other as AnnouncementParameters + + if (image != other.image) return false + if (sendToNewMember != other.sendToNewMember) return false + if (isPinned != other.isPinned) return false + if (isShowEditCard != other.isShowEditCard) return false + if (isTip != other.isTip) return false + if (needConfirm != other.needConfirm) return false + + return true + } + + override fun hashCode(): Int { + var result = image?.hashCode() ?: 0 + result = 31 * result + sendToNewMember.hashCode() + result = 31 * result + isPinned.hashCode() + result = 31 * result + isShowEditCard.hashCode() + result = 31 * result + isTip.hashCode() + result = 31 * result + needConfirm.hashCode() + return result + } + + override fun toString(): String { + return "AnnouncementParameters(image=$image, sendToNewMember=$sendToNewMember, isPinned=$isPinned, isShowEditCard=$isShowEditCard, isTip=$isTip, needConfirm=$needConfirm)" + } } \ No newline at end of file