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
d4321152
Commit
d4321152
authored
Feb 14, 2020
by
jiahua.liu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Thread safety
parent
425de4ae
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
22 deletions
+18
-22
mirai-console/src/main/kotlin/net/mamoe/mirai/plugins/ConfigSection.kt
.../src/main/kotlin/net/mamoe/mirai/plugins/ConfigSection.kt
+18
-22
No files found.
mirai-console/src/main/kotlin/net/mamoe/mirai/plugins/ConfigSection.kt
View file @
d4321152
...
...
@@ -284,15 +284,8 @@ open class ConfigSectionImpl() : ConcurrentHashMap<String, Any>(), ConfigSection
}
}
interface
FileConfig
:
Config
{
fun
deserialize
(
content
:
String
):
ConfigSection
fun
serialize
(
config
:
ConfigSection
):
String
}
open
class
ConfigSectionDelegation
(
val
delegation
:
MutableMap
<
String
,
Any
>
private
val
delegation
:
MutableMap
<
String
,
Any
>
)
:
ConfigSection
,
MutableMap
<
String
,
Any
>
by
delegation
{
override
fun
set
(
key
:
String
,
value
:
Any
)
{
delegation
.
put
(
key
,
value
)
...
...
@@ -307,6 +300,14 @@ open class ConfigSectionDelegation(
}
}
interface
FileConfig
:
Config
{
fun
deserialize
(
content
:
String
):
ConfigSection
fun
serialize
(
config
:
ConfigSection
):
String
}
abstract
class
FileConfigImpl
internal
constructor
(
private
val
file
:
File
)
:
FileConfig
,
ConfigSection
{
...
...
@@ -315,18 +316,10 @@ abstract class FileConfigImpl internal constructor(
deserialize
(
file
.
readText
())
}
override
val
size
:
Int
get
()
=
content
.
size
override
val
entries
:
MutableSet
<
MutableMap
.
MutableEntry
<
String
,
Any
>>
get
()
=
content
.
entries
override
val
keys
:
MutableSet
<
String
>
get
()
=
content
.
keys
override
val
values
:
MutableCollection
<
Any
>
get
()
=
content
.
values
override
val
size
:
Int
get
()
=
content
.
size
override
val
entries
:
MutableSet
<
MutableMap
.
MutableEntry
<
String
,
Any
>>
get
()
=
content
.
entries
override
val
keys
:
MutableSet
<
String
>
get
()
=
content
.
keys
override
val
values
:
MutableCollection
<
Any
>
get
()
=
content
.
values
override
fun
containsKey
(
key
:
String
):
Boolean
=
content
.
containsKey
(
key
)
override
fun
containsValue
(
value
:
Any
):
Boolean
=
content
.
containsValue
(
value
)
override
fun
put
(
key
:
String
,
value
:
Any
):
Any
?
=
content
.
put
(
key
,
value
)
...
...
@@ -335,7 +328,6 @@ abstract class FileConfigImpl internal constructor(
override
fun
clear
()
=
content
.
clear
()
override
fun
remove
(
key
:
String
):
Any
?
=
content
.
remove
(
key
)
override
fun
save
()
{
if
(!
file
.
exists
())
{
file
.
createNewFile
()
...
...
@@ -401,7 +393,11 @@ class TomlConfig internal constructor(file: File) : FileConfigImpl(file) {
if
(
content
.
isEmpty
()
||
content
.
isBlank
())
{
return
ConfigSectionImpl
()
}
return
ConfigSectionDelegation
(
Toml
().
read
(
content
).
toMap
())
return
ConfigSectionDelegation
(
Collections
.
synchronizedMap
(
Toml
().
read
(
content
).
toMap
()
)
)
}
override
fun
serialize
(
config
:
ConfigSection
):
String
{
...
...
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