当前位置:网站首页>Meta annotation (annotation of annotation)
Meta annotation (annotation of annotation)
2022-04-23 05:47:00 【DK_ ten thousand and thirty-two】
List of articles
Reprinted from :https://www.cnblogs.com/lqtbk/p/10141455.html
Yuan notes ( Notes to notes )
1. @Retention
It is defined in front of an annotation class , Used to describe the life cycle of the annotation .
It has the following parameters :
RetentionPolicy.SOURCE: Specifies that the annotation is only kept in the source file .
RetentionPolicy.CLASS: Specifies that the annotation is reserved only in class In file .( default )
RetentionPolicy.RUNTIME: Specifies that annotations can be retained during program execution .
2. @Target
It is defined in front of an annotation class , Used to indicate which elements the annotation can be declared in front of .( By default, it can be placed before any element )
It has the following parameters :
ElementType.TYPE: Note that the annotation can only be declared in one class 、 Interface 、 Before enumeration .
ElementType.FIELD: The annotation can only be declared before the field of a class .
ElementType.METHOD: The annotation can only be declared before the method of a class .
ElementType.PARAMETER: Indicates that the annotation can only be declared before a method parameter .
ElementType.CONSTRUCTOR: The annotation can only be declared before the constructor of a class .
ElementType.LOCAL_VARIABLE: The annotation can only be declared before a local variable .
ElementType.ANNOTATION_TYPE: Indicates that the annotation can only be declared before an annotation type .
ElementType.PACKAGE: The annotation can only be declared before a package name .
3. @Inherited Indicates that the annotation will be inherited by subclasses .
It should be noted that , Annotation with this meta annotation , Only when used on class elements can it work . This is JDK General original words :
Note that this meta-annotation type has no effect if the annotated type is used to annotate anything other than a class. Note also that this meta-annotation only causes annotations to be inherited from superclasses; annotations on implemented interfaces have no effect
But annotations on other elements , As long as you don't override the elements in the parent class , It will be inherited . That's why there are getDeclaredAnnotations() and getAnnotations() Why .
4. @Documented
Indicates that the JavaDoc When the document , The annotation will also appear in javaDoc In the document .
版权声明
本文为[DK_ ten thousand and thirty-two]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220534093717.html
边栏推荐
- Linear sieve method (prime sieve)
- solidity合约DOS攻击
- 热键,界面可视化配置(界面交互)
- qt. qpa. plugin: Could not find the Qt platform plugin “xcb“ in ““
- ES6之解构函数
- 实体中list属性为空或者null,设置为空数组
- acwing854. Floyd finds the shortest path
- deep learning object detection
- Differences between sea level anatomy and sea surface height anatomy
- OSI层常用协议
猜你喜欢
第36期《AtCoder Beginner Contest 248 打比赛总结》
Batch import of orange single micro service
Fletter next generation graphics renderer impaller
Pilotage growth · ingenuity empowerment -- yonmaster developer training and pilotage plan is fully launched
C, class library
Some pits used by uni
Find the number of "blocks" in the matrix (BFS)
Frequently asked interview questions - 2 (computer network)
2 - principes de conception de logiciels
Interview Basics
随机推荐
STD:: String implements split
solidity合约DOS攻击
Several examples of pointer transfer, parameter transfer, value transfer, etc
Navicate连接oracle(11g)时ORA:28547 Connection to server failed probable Oeacle Net admin error
AcWing 836. Merge set (merge set)
多个一维数组拆分合并为二维数组
College entrance examination volunteer filling reference
Add two pointers? (legal or illegal)
Batch import of orange single micro service
io.lettuce.core.RedisCommandExecutionException: ERR wrong number of arguments for ‘auth‘ command
io. lettuce. core. RedisCommandExecutionException: ERR wrong number of arguments for ‘auth‘ command
World and personal development
2-軟件設計原則
Map对象 map.get(key)
7-10 longest symmetric substring (25 points) (violence problem solution) C language
Common protocols of OSI layer
Strategies to improve Facebook's touch rate and interaction rate | intelligent customer service helps you grasp users' hearts
deep learning object detection
No.1.#_ 6 Navicat shortcuts
POI generates excel and inserts pictures