@x-power
2019-09-16T12:27:40.000000Z
字数 956
阅读 575
Custom nnotation
Java注解
1. The concept of annotation
- An annotation is a form of metadata, that can be added to Java source code. Classes, methods, variables, parameters and packages may be annotated. Annotations have no direct effect on the operation of the code they annotate.
We can draw the following conclusions from the official description:
- An annotation is a form of metadata, just like class ,interface ,array ,enumerate .
- Annotations are used to modify classes, methods, variables, parameters, packages.
- Annotations have no direct effect on the operation of the code they annotate.
2. How to customize annotations
An annotation is simply a tag that can be stamped on key points in program code (classes, methods, variables, parameters, packages) and then detected at compile time or run time to perform special operations.So we can see the basic flow of custom annotation usage:
- Customize annotations --- Equivalent to definition mark
- Configuration annotations --- Place the tag on top of the program code you need to use
- Parse annotations --- tags are detected at compile time or run time and special operations are performed.