scanAnnotations
Scans for all annotations of the specified type on the annotated element, including inherited annotations from parent classes and interfaces.
Return
a list of all matching annotations found on the element
class MyClass {
@MyAnnotation
fun myMethod() {}
}
val method = MyClass::class.members.find { it.name == "myMethod" }!!
val annotations = method.scanAnnotations(MyAnnotation::class)Content copied to clipboard
Parameters
annotationClass
the KClass representing the annotation type
Type Parameters
A
the type of annotation to scan for
Scans for all annotations of the specified reified type on the annotated element. This is a convenience method that uses reified generics to avoid specifying the class explicitly.
Return
a list of all matching annotations found on the element
val annotations = myClass.scanAnnotations<SuppressWarnings>()Content copied to clipboard
Type Parameters
A
the type of annotation to scan for