scanAnnotation

fun <A : Annotation> KAnnotatedElement.scanAnnotation(annotationClass: KClass<A>): A?

Scans for the first annotation of the specified type on the annotated element. Returns null if no matching annotation is found.

Return

the first matching annotation, or null if none found

Parameters

A

the type of annotation to scan for

annotationClass

the KClass representing the annotation type

Samples


Scans for the first annotation 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

the first matching annotation, or null if none found

Parameters

A

the type of annotation to scan for

Samples