JAva注釈入門

1967 ワード

1.メタ注記
/**
 * @author bobo ([email protected])
 * @date 2018 01 28 
 * @desc        
 */


/**
 *    :         ,    @Documented, @Target, @Inherited, @Retention   
 *
 * 1. @Documented            javadoc    
 *           , javadoc       ,           @Documented,        javadoc       ,
 *                          .
 *
 * 2. @Target            , Target   ElementType               
 *          :
 *          ElementType.METHOD                        
 *          ElementType.TYPE                            
 *          ElementType.ANNOTATION_TYPE                  (  @interface     )
 *          ElementType.CONSTRUCTOR                     
 *          ElementType.FIELD                         
 *          ElementType.LOCAL_VARIABLE                  
 *          ElementType.PACKAGE                      java    package  
 *          ElementType.PARAMETER                     
 *
 *
 * 3. @Inherited                 
 *              @Inherited    Annotation        ,      Annotation      class   
 *        :
 *        1. @Inherited annotation         class      .               annotation
 *                              annotation
 *        2.   @Inherited annotation      annotation  Retention  RetentionPolicy.RUNTIME,     API        
 *                     java.lang.reflect      @Inherited annotation    annotation ,          :
 *                 class    ,       annotation     ,             
 *
 *
 * 4. @Retention (  )      Java      ,     
 *      * RetentionPolicy.SOURCE                    ,         
 *      * RetentionPolicy.CLASS                    ,   class     ,   JVM    
 *      * RetentionPolicy.RUNTIME             JVM  ,            JVM                  
 *
 */

@Documented
@Target({ElementType.METHOD, ElementType.FIELD})
@Inherited
@Retention(RetentionPolicy.RUNTIME)
public @interface DataSourceSelector {

    String value();
    
}

参考記事
1.JDK 5 Annotation注記の@Targetの使い方の紹介
2.Java注釈チュートリアルおよびカスタム注釈