mirror of
https://github.com/mamoe/mirai.git
synced 2025-02-11 18:10:26 +08:00
Add hashCode
and equals
for Image
, close #1302
This commit is contained in:
parent
f7170f2052
commit
eb5c7414d7
@ -219,6 +219,13 @@ public sealed class AbstractImage : Image {
|
|||||||
override fun appendMiraiCodeTo(builder: StringBuilder) {
|
override fun appendMiraiCodeTo(builder: StringBuilder) {
|
||||||
builder.append("[mirai:image:").append(imageId).append("]")
|
builder.append("[mirai:image:").append(imageId).append("]")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final override fun hashCode(): Int = imageId.hashCode()
|
||||||
|
final override fun equals(other: Any?): Boolean {
|
||||||
|
if (other === this) return true
|
||||||
|
if (other !is Image) return false
|
||||||
|
return this.imageId == other.imageId
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -55,13 +55,6 @@ internal class OnlineGroupImageImpl(
|
|||||||
}/0?term=2"
|
}/0?term=2"
|
||||||
} else "http://gchat.qpic.cn" + delegate.origUrl
|
} else "http://gchat.qpic.cn" + delegate.origUrl
|
||||||
|
|
||||||
override fun equals(other: Any?): Boolean {
|
|
||||||
return other is OnlineGroupImageImpl && other.imageId == this.imageId
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun hashCode(): Int {
|
|
||||||
return imageId.hashCode() + 31 * md5.hashCode()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Serializable(with = OnlineFriendImageImpl.Serializer::class)
|
@Serializable(with = OnlineFriendImageImpl.Serializer::class)
|
||||||
@ -97,13 +90,6 @@ OnlineFriendImage() {
|
|||||||
}
|
}
|
||||||
// TODO: 2020/4/24 动态获取图片下载链接的 host
|
// TODO: 2020/4/24 动态获取图片下载链接的 host
|
||||||
|
|
||||||
override fun equals(other: Any?): Boolean {
|
|
||||||
return other is OnlineFriendImageImpl && other.imageId == this.imageId
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun hashCode(): Int {
|
|
||||||
return imageId.hashCode() + 31 * md5.hashCode()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user