Commit f765804f authored by Him188's avatar Him188

Make `MessageMetadata.contentToString` final

parent b0089d58
...@@ -190,8 +190,6 @@ abstract class CustomMessageMetadata : CustomMessage(), MessageMetadata { ...@@ -190,8 +190,6 @@ abstract class CustomMessageMetadata : CustomMessage(), MessageMetadata {
final override fun toString(): String = final override fun toString(): String =
"[mirai:custom:${getFactory().typeName}:${String(customToString())}]" "[mirai:custom:${getFactory().typeName}:${String(customToString())}]"
final override fun contentToString(): String = ""
} }
......
...@@ -297,7 +297,13 @@ interface SingleMessage : Message { ...@@ -297,7 +297,13 @@ interface SingleMessage : Message {
* *
* @see ConstrainSingle 约束一个 [MessageChain] 中只存在这一种类型的元素 * @see ConstrainSingle 约束一个 [MessageChain] 中只存在这一种类型的元素
*/ */
interface MessageMetadata : SingleMessage interface MessageMetadata : SingleMessage {
/**
* 返回空字符串
*/
@Suppress("WRONG_MODIFIER_CONTAINING_DECLARATION")
final override fun contentToString(): String = ""
}
/** /**
* 约束一个 [MessageChain] 中只存在这一种类型的元素. 新元素将会替换旧元素, 保持原顺序. * 约束一个 [MessageChain] 中只存在这一种类型的元素. 新元素将会替换旧元素, 保持原顺序.
......
...@@ -132,11 +132,6 @@ sealed class MessageSource : Message, MessageMetadata, ConstrainSingle<MessageSo ...@@ -132,11 +132,6 @@ sealed class MessageSource : Message, MessageMetadata, ConstrainSingle<MessageSo
* 返回 `"[mirai:source:$id,$internalId]"` * 返回 `"[mirai:source:$id,$internalId]"`
*/ */
final override fun toString(): String = "[mirai:source:$id,$internalId]" final override fun toString(): String = "[mirai:source:$id,$internalId]"
/**
* 返回空字符串, 因 [MessageMetadata] 的约束.
*/
final override fun contentToString(): String = ""
} }
......
...@@ -55,7 +55,6 @@ class QuoteReply(val source: MessageSource) : Message, MessageMetadata, Constrai ...@@ -55,7 +55,6 @@ class QuoteReply(val source: MessageSource) : Message, MessageMetadata, Constrai
override val key: Message.Key<QuoteReply> get() = Key override val key: Message.Key<QuoteReply> get() = Key
override fun toString(): String = "[mirai:quote:${source.id},${source.internalId}]" override fun toString(): String = "[mirai:quote:${source.id},${source.internalId}]"
override fun contentToString(): String = ""
override fun equals(other: Any?): Boolean = other is QuoteReply && other.source == this.source override fun equals(other: Any?): Boolean = other is QuoteReply && other.source == this.source
override fun hashCode(): Int = source.hashCode() override fun hashCode(): Int = source.hashCode()
} }
......
...@@ -26,10 +26,6 @@ internal class TestConstrainSingleMessage : ConstrainSingle<TestConstrainSingleM ...@@ -26,10 +26,6 @@ internal class TestConstrainSingleMessage : ConstrainSingle<TestConstrainSingleM
override fun toString(): String = "<TestConstrainSingleMessage#${super.hashCode()}>" override fun toString(): String = "<TestConstrainSingleMessage#${super.hashCode()}>"
override fun contentToString(): String {
return ""
}
override val key: Message.Key<TestConstrainSingleMessage> override val key: Message.Key<TestConstrainSingleMessage>
get() = Key get() = Key
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment