# Annotations
# Declaring an annotation
Annotations are means of attaching metadata to code. To declare an annotation, put the annotation modifier in front of a class:
annotation class Strippable
Annotations can have meta-anotations:
@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION, AnnotationTarget.VALUE_PARAMETER, AnnotationTarget.EXPRESSION)
annotation class Strippable
Annotations, like other classes, can have constructors:
annotation class Strippable(val importanceValue: Int)
But unlike other classes, is limited to the following types:
- types that correspond to Java primitive types (Int, Long etc.);
- strings
- classes ( Foo:: class)
- enums
- other annotations
- arrays of the types listed above
# Meta-annotations
When declaring an annotation, meta-info can be included using the following meta-annotations:
Example:
@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION,
AnnotationTarget.VALUE_PARAMETER, AnnotationTarget.EXPRESSION)
@Retention(AnnotationRetention.SOURCE)
@MustBeDocumented
annotation class Fancy