aboutsummaryrefslogtreecommitdiff
path: root/src/Utilities/ServiceLocator.kt
diff options
context:
space:
mode:
Diffstat (limited to 'src/Utilities/ServiceLocator.kt')
-rw-r--r--src/Utilities/ServiceLocator.kt14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/Utilities/ServiceLocator.kt b/src/Utilities/ServiceLocator.kt
index b3610a53..bc04238f 100644
--- a/src/Utilities/ServiceLocator.kt
+++ b/src/Utilities/ServiceLocator.kt
@@ -2,7 +2,7 @@ package org.jetbrains.dokka.Utilities
import org.jetbrains.dokka.DokkaGenerator
import java.io.File
-import java.util.Properties
+import java.util.*
import java.util.jar.JarFile
import java.util.zip.ZipEntry
@@ -16,7 +16,7 @@ public object ServiceLocator {
val loadedClass = javaClass.classLoader.loadClass(descriptor.className)
val constructor = loadedClass.constructors
.filter { it.parameterTypes.isEmpty() || (it.parameterTypes.size() == 1 && conf.javaClass.isInstance(it.parameterTypes[0])) }
- .sortDescendingBy { it.parameterTypes.size() }
+ .sortedByDescending { it.parameterTypes.size() }
.firstOrNull() ?: throw ServiceLookupException("Class ${descriptor.className} has no corresponding constructor")
val implementationRawType: Any = if (constructor.parameterTypes.isEmpty()) constructor.newInstance() else constructor.newInstance(constructor)
@@ -25,7 +25,7 @@ public object ServiceLocator {
throw ServiceLookupException("Class ${descriptor.className} is not a subtype of ${clazz.name}")
}
- @suppress("UNCHECKED_CAST")
+ @Suppress("UNCHECKED_CAST")
return implementationRawType as T
}
@@ -35,7 +35,7 @@ public object ServiceLocator {
throw ServiceLookupException("Class $className is not a subtype of ${clazz.name}")
}
- @suppress("UNCHECKED_CAST")
+ @Suppress("UNCHECKED_CAST")
val casted = loaded as Class<T>
casted
@@ -89,6 +89,12 @@ public inline fun <reified T : Any> ServiceLocator.lookupOrNull(category: String
null
}
+fun main(args: Array<String>) {
+ ServiceLocator.allServices("format").forEach {
+ println(it)
+ }
+}
+
private val ZipEntry.fileName: String
get() = name.substringAfterLast("/", name)