Annotations
Kotlin annotation usage and creation of annotation classes
Creating an annotation in Kotlin
To create an annotation in Kotlin prefix the class
definition with annotation
and annotate the class with the desired @Target
and @Retention
scope.
Example:
@Target(AnnotationTarget.FUNCTION)
@Retention(AnnotationRetention.SOURCE)
annotation class IgnoreNull
The constructor of the annotation are the properties that can be set while annotating the desired target. For instance:
@Target(AnnotationTarget.FUNCTION)
@Retention(AnnotationRetention.SOURCE)
annotation class IgnoreNull(val scope:String)