All Downloads are FREE. Search and download functionalities are using the official Maven repository.

walkmc.extensions.Reflection.kt Maven / Gradle / Ivy

package walkmc.extensions

import kotlin.reflect.*
import kotlin.reflect.full.*
import kotlin.reflect.jvm.*

/**
 * Returns a specified constructor of this class searching by parameters type
 * or null if this class not have any constructor of the given types.
 */
fun  KClass.constructor(vararg types: KClass<*>): KFunction? =
   java.getConstructor(*types.map(KClass<*>::java).toTypedArray()).kotlinFunction

/**
 * Returns all functions that's is annoted with the type [T].
 */
inline fun  KClass<*>.findFunctionsAnnotedWith(): List> {
   return functions.filter { it.hasAnnotation() }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy