KAnnotationTool

KAnnotation tool interface.

The KAnnotation tool interface provides some abstract methods to define some operations for annotations, such as .getAnnotation, .getProperties or directly constructing an annotation instance, etc.

You can implement this interface any way you like, but of course, the library provides a default implementation, as well as an implementation of the instance provided by KAnnotationTool: SimpleKAnnotationTool.

Author

ForteScarlet

See also

Functions

Link copied to clipboard
abstract fun clearCache()

Clean internal annotation instance cache. (if exists.)

Link copied to clipboard
inline fun <A : Annotation> KAnnotationTool.createAnnotation(properties: Map<String, Any> = emptyMap(), base: A? = null): A
Link copied to clipboard
open fun <A : Annotation> createAnnotationInstance(annotationType: KClass<A>): A
open fun <A : Annotation> createAnnotationInstance(annotationType: KClass<A>, properties: Map<String, Any>): A

Create an annotation proxy instance.

abstract fun <A : Annotation> createAnnotationInstance(annotationType: KClass<A>, properties: Map<String, Any>, base: A?): A

Create an annotation instance.

Link copied to clipboard
open fun <A : Annotation> getAnnotation(fromElement: KAnnotatedElement, annotationType: KClass<A>): A?

Get annotation instance fromElement KAnnotatedElement. e.g. fromElement Function or KClass.

abstract fun <A : Annotation> getAnnotation(fromElement: KAnnotatedElement, annotationType: KClass<A>, excludes: Set<String>): A?

Get annotation instance from KAnnotatedElement. e.g. from Function or KClass.

Link copied to clipboard
inline fun <A : Annotation> KAnnotationTool.getAnnotation(element: KAnnotatedElement, exclude: Set<String> = emptySet()): A?
Link copied to clipboard
abstract fun getAnnotationPropertyTypes(annotationType: KClass<out Annotation>): Map<String, KType>

Get annotation type's value types.

Link copied to clipboard
open fun <A : Annotation> getAnnotations(element: KAnnotatedElement, annotationType: KClass<A>): List<A>

Get a repeatable annotation instance from KAnnotatedElement. e.g. from Function or KClass.

abstract fun <A : Annotation> getAnnotations(element: KAnnotatedElement, annotationType: KClass<A>, excludes: Set<String>): List<A>

Get annotation instance list from KAnnotatedElement.

Link copied to clipboard
inline fun <A : Annotation> KAnnotationTool.getAnnotations(element: KAnnotatedElement, exclude: Set<String> = emptySet()): List<A>
Link copied to clipboard
abstract fun <A : Annotation> getAnnotationValues(annotation: A): Map<String, Any>

Get annotation values.

Link copied to clipboard
open fun getProperties(annotation: Annotation): Set<String>
Link copied to clipboard
abstract fun getPropertyNames(annotation: Annotation): Set<String>

Get annotation property names.