name.remal.kotlin.reflect.KFunction.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of common Show documentation
Show all versions of common Show documentation
Java & Kotlin tools: common
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)