Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
Mirai
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
Mirai
Commits
c4b3eade
Commit
c4b3eade
authored
Apr 20, 2020
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
`MessageChain.firstOrNull` rather than `MessageChain.getOrNull` on JVM
parent
0689f84b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
2 deletions
+13
-2
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/data/MessageChain.kt
...nMain/kotlin/net.mamoe.mirai/message/data/MessageChain.kt
+13
-2
No files found.
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/data/MessageChain.kt
View file @
c4b3eade
...
...
@@ -60,15 +60,18 @@ interface MessageChain : Message, Iterable<SingleMessage> {
* @param key 由各个类型消息的伴生对象持有. 如 [PlainText.Key]
* @throws NoSuchElementException 当找不到这个类型的 [Message] 时
*/
@Suppress
(
"INAPPLICABLE_JVM_NAME"
)
@JvmName
(
"first"
)
operator
fun
<
M
:
Message
>
get
(
key
:
Message
.
Key
<
M
>):
M
=
first
(
key
)
/* final */
operator
fun
<
M
:
Message
>
get
(
key
:
Message
.
Key
<
M
>):
M
=
first
(
key
)
/**
* 获取第一个类型为 [key] 的 [Message] 实例, 找不到则返回 `null`
*
* @param key 由各个类型消息的伴生对象持有. 如 [PlainText.Key]
*/
fun
<
M
:
Message
>
getOrNull
(
key
:
Message
.
Key
<
M
>):
M
?
=
firstOrNull
(
key
)
@Suppress
(
"INAPPLICABLE_JVM_NAME"
)
@JvmName
(
"firstOrNull"
)
/* final */
fun
<
M
:
Message
>
getOrNull
(
key
:
Message
.
Key
<
M
>):
M
?
=
firstOrNull
(
key
)
/**
* 遍历每一个有内容的消息, 即 [At], [AtAll], [PlainText], [Image], [Face], [XmlMessage], [QuoteReply].
...
...
@@ -94,11 +97,19 @@ interface MessageChain : Message, Iterable<SingleMessage> {
this
.
forEach
(
block
)
}
@PlannedRemoval
(
"1.0.0"
)
@Deprecated
(
"for binary compatibility"
,
level
=
DeprecationLevel
.
HIDDEN
)
@JvmSynthetic
@Suppress
(
"FunctionName"
,
"INAPPLICABLE_JVM_NAME"
)
@JvmName
(
"get"
)
fun
<
M
:
Message
>
get2
(
key
:
Message
.
Key
<
M
>):
M
=
first
(
key
)
@PlannedRemoval
(
"1.0.0"
)
@Deprecated
(
"for binary compatibility"
,
level
=
DeprecationLevel
.
HIDDEN
)
@JvmSynthetic
@Suppress
(
"FunctionName"
,
"INAPPLICABLE_JVM_NAME"
)
@JvmName
(
"getOrNull"
)
fun
<
M
:
Message
>
getOrNull2
(
key
:
Message
.
Key
<
M
>):
M
?
=
getOrNull
(
key
)
}
// region accessors
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment