net.bjoernpetersen.musicbot.api.plugin.management.DependencyFinder.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of musicbot Show documentation
Show all versions of musicbot Show documentation
Core library of MusicBot, which plays music from various providers.
package net.bjoernpetersen.musicbot.api.plugin.management
import com.google.inject.spi.InjectionPoint
import net.bjoernpetersen.musicbot.spi.plugin.Plugin
import kotlin.reflect.KClass
import kotlin.reflect.full.isSubclassOf
/**
* Find the immediate dependencies of a plugin.
*/
fun Plugin.findDependencies(): Set> {
return InjectionPoint.forInstanceMethodsAndFields(this::class.java)
.asSequence()
.flatMap { it.dependencies.asSequence() }
.map { it.key }
.map { it.typeLiteral.rawType }
.map { it as Class }
.map { it.kotlin }
.filter { it.isSubclassOf(Plugin::class) }
.map {
@Suppress("UNCHECKED_CAST")
it as KClass
}
.toSet()
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy