Annotations, a form of metadata, provide data about a program that is not part of the program itself. Annotations have no direct effect on the operation of the code they annotate。
一般来说Annotation有如下三种使用情形:
- Information for the compiler — Annotations can be used by the compiler to detect errors or suppress * warnings.**
- Compile-time and deployment-time processing — Software tools can process annotation information to generate code, XML files, and so forth.
- Runtime processing— Some annotations are available to be examined at runtime.
- 为编译器提供辅助信息 — Annotations可以为编译器提供而外信息,以便于检测错误,抑制警告等.
- 编译源代码时进行而外操作 — 软件工具可以通过处理Annotation信息来生成原代码,xml文件等等.
- 运行时处理 — 有一些annotation甚至可以在程序运行时被检测,使用.
参考资料:
https://www.race604.com/annotation-processing/
http://hannesdorfmann.com/annotation-processing/annotationprocessing101
http://blog.csdn.net/xfxyy_sxfancy/article/details/44275549#t3