Custom annotation notes in common

Custom annotation notes in common:

Meta annotation has four java @Retention @Target @Document @Inherited ;

    @Retention: annotation reserved locations         

      @Retention (RetentionPolicy.SOURCE)   // annotations in the source code is present only in the class bytecode file does not contain

      @ retention (RetentionPolicy.CLASS)      // default retention policy, annotations exist in the class bytecode file, but could not get run

      @Retention (RetentionPolicy.RUNTIME)   // annotations will exist in the class bytecode file, in can be obtained by the run-time reflection ( runtime active )

 

  @Target: the role of the target annotation


        @Target (ElementType.TYPE)   // interfaces, classes, enumeration

        @Target (ElementType.FIELD)  // field enumeration constants

        @Target (ElementType.METHOD)  // method

        @Target (ElementType.PARAMETER) // Method parameter

        @Target (ElementType.CONSTRUCTOR)  // constructor

        @Target (ElementType.LOCAL_VARIABLE) // local variable

        @Target (ElementType.ANNOTATION_TYPE) // annotation

        @Target (ElementType.PACKAGE)  /// package  

     @Document: Description of the annotated It will be included in the javadoc

   @Inherited: Description subclasses inherit the parent class annotation


----------------
Original link: https: //blog.csdn.net/sw5131899/article/details/54947192

Guess you like

Origin www.cnblogs.com/wdss/p/11842590.html