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

name.remal.kotlin.reflect.KFunction.kt Maven / Gradle / Ivy

There is a newer version: 1.26.147
Show newest version
package name.remal

import kotlin.reflect.KFunction
import kotlin.reflect.jvm.javaConstructor
import kotlin.reflect.jvm.javaMethod

fun  KFunction<*>.getMetaAnnotations(type: Class): List {
    val result = mutableSetOf()
    javaMethod?.getMetaAnnotations(type)?.forEach { result.add(it) }
    javaConstructor?.getMetaAnnotations(type)?.forEach { result.add(it) }
    return result.toList()
}

fun  KFunction<*>.getMetaAnnotation(type: Class) = getMetaAnnotations(type).firstOrNull()
fun  KFunction<*>.hasMetaAnnotation(type: Class) = null != getMetaAnnotation(type)




© 2015 - 2024 Weber Informatics LLC | Privacy Policy