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
7a6a5896
Commit
7a6a5896
authored
Feb 21, 2020
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add `contains` support
parent
2dfcb224
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
5 deletions
+20
-5
mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugins/ConfigSection.kt
...n/kotlin/net/mamoe/mirai/console/plugins/ConfigSection.kt
+20
-5
No files found.
mirai-console/src/main/kotlin/net/mamoe/mirai/console/plugins/ConfigSection.kt
View file @
7a6a5896
...
@@ -15,7 +15,8 @@ import com.alibaba.fastjson.TypeReference
...
@@ -15,7 +15,8 @@ import com.alibaba.fastjson.TypeReference
import
com.alibaba.fastjson.parser.Feature
import
com.alibaba.fastjson.parser.Feature
import
com.moandjiezana.toml.Toml
import
com.moandjiezana.toml.Toml
import
com.moandjiezana.toml.TomlWriter
import
com.moandjiezana.toml.TomlWriter
import
kotlinx.serialization.*
import
kotlinx.serialization.Serializable
import
kotlinx.serialization.UnstableDefault
import
org.yaml.snakeyaml.Yaml
import
org.yaml.snakeyaml.Yaml
import
java.io.File
import
java.io.File
import
java.util.*
import
java.util.*
...
@@ -48,6 +49,7 @@ interface Config {
...
@@ -48,6 +49,7 @@ interface Config {
fun
getLongList
(
key
:
String
):
List
<
Long
>
fun
getLongList
(
key
:
String
):
List
<
Long
>
operator
fun
set
(
key
:
String
,
value
:
Any
)
operator
fun
set
(
key
:
String
,
value
:
Any
)
operator
fun
get
(
key
:
String
):
Any
?
operator
fun
get
(
key
:
String
):
Any
?
operator
fun
contains
(
key
:
String
):
Boolean
fun
exist
(
key
:
String
):
Boolean
fun
exist
(
key
:
String
):
Boolean
fun
setIfAbsent
(
key
:
String
,
value
:
Any
)
fun
setIfAbsent
(
key
:
String
,
value
:
Any
)
fun
asMap
():
Map
<
String
,
Any
>
fun
asMap
():
Map
<
String
,
Any
>
...
@@ -280,6 +282,11 @@ open class ConfigSectionImpl() : ConcurrentHashMap<String, Any>(),
...
@@ -280,6 +282,11 @@ open class ConfigSectionImpl() : ConcurrentHashMap<String, Any>(),
return
super
.
get
(
key
)
return
super
.
get
(
key
)
}
}
@Suppress
(
"RedundantOverride"
)
override
fun
contains
(
key
:
String
):
Boolean
{
return
super
.
contains
(
key
)
}
override
fun
exist
(
key
:
String
):
Boolean
{
override
fun
exist
(
key
:
String
):
Boolean
{
return
containsKey
(
key
)
return
containsKey
(
key
)
}
}
...
@@ -298,14 +305,18 @@ open class ConfigSectionImpl() : ConcurrentHashMap<String, Any>(),
...
@@ -298,14 +305,18 @@ open class ConfigSectionImpl() : ConcurrentHashMap<String, Any>(),
}
}
open
class
ConfigSectionDelegation
(
open
class
ConfigSectionDelegation
(
private
val
delegat
ion
:
MutableMap
<
String
,
Any
>
private
val
delegat
e
:
MutableMap
<
String
,
Any
>
)
:
ConfigSection
,
MutableMap
<
String
,
Any
>
by
delegat
ion
{
)
:
ConfigSection
,
MutableMap
<
String
,
Any
>
by
delegat
e
{
override
fun
set
(
key
:
String
,
value
:
Any
)
{
override
fun
set
(
key
:
String
,
value
:
Any
)
{
delegation
.
put
(
key
,
value
)
delegate
.
put
(
key
,
value
)
}
override
fun
contains
(
key
:
String
):
Boolean
{
return
delegate
.
containsKey
(
key
)
}
}
override
fun
asMap
():
Map
<
String
,
Any
>
{
override
fun
asMap
():
Map
<
String
,
Any
>
{
return
delegat
ion
return
delegat
e
}
}
override
fun
save
()
{
override
fun
save
()
{
...
@@ -349,6 +360,10 @@ abstract class FileConfigImpl internal constructor(
...
@@ -349,6 +360,10 @@ abstract class FileConfigImpl internal constructor(
file
.
writeText
(
serialize
(
content
))
file
.
writeText
(
serialize
(
content
))
}
}
override
fun
contains
(
key
:
String
):
Boolean
{
return
content
.
contains
(
key
)
}
override
fun
get
(
key
:
String
):
Any
?
{
override
fun
get
(
key
:
String
):
Any
?
{
return
content
[
key
]
return
content
[
key
]
}
}
...
...
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