Commit 7e1a4c57 authored by Mygod's avatar Mygod

Ensure no duplicate ID/aliases

parent fbeb11a2
......@@ -31,10 +31,11 @@ class PluginList : ArrayList<Plugin>() {
Intent(PluginContract.ACTION_NATIVE_PLUGIN), PackageManager.GET_META_DATA).map { NativePlugin(it) })
}
val lookup = flatMap { plugin ->
sequence {
yield(plugin.id to plugin)
for (alias in plugin.idAliases) yield(alias to plugin)
}.asIterable()
}.associate { it }
val lookup = mutableMapOf<String, Plugin>().apply {
for (plugin in this@PluginList) {
fun check(old: Plugin?) = check(old == null || old === plugin)
check(put(plugin.id, plugin))
for (alias in plugin.idAliases) check(put(alias, plugin))
}
}
}
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