chenitu 2022-06-24 08:01:11 阅读数:793
java Classification of annotations : Standard notes 、 Yuan notes 、 Custom annotation
Include @Override、@Deprecated、@SuppressWarnings etc. , After using these annotations, the compiler checks .
JDK The following comments are built in :
Meta annotations are annotations used to define annotations , Include @Retention、@Target、@Inherited、@Documented、@Repeatable etc. . Meta annotation is also Java Own standard notes , Just used to decorate other annotations .
Meta annotations are java API Provided , Is a comment used to modify an annotation , Usually used in the definition of annotation :
@Documented: Keep annotations when generating document information , Auxiliary description of class
@Target Illustrates the Annotation The scope of the object being decorated :Annotation Can be used for packages、types( class 、 Interface 、 enumeration 、Annotation type )、 Type members ( Method 、 Construction method 、 Member variables 、 Enumerated values )、 Method parameters and local variables ( Like loop variables 、catch Parameters ). stay Annotation Used in the declaration of type target Can be more clear about its embellishment objectives .
Users can define annotations according to their own needs . When we understand the built-in annotation , After meta annotation and reflection interface to get annotation , We can start customizing annotations . Creating custom annotations is similar to creating an interface , But annotated interface Keywords need to be @ Symbol at the beginning , We can declare methods for annotations .
copyright:author[chenitu],Please bring the original link to reprint, thank you. https://en.javamana.com/2022/175/202206240236531060.html