当前位置: 代码迷 >> 综合 >> @Documented Annotation的使用
  详细解决方案

@Documented Annotation的使用

热度:32   发布时间:2024-01-09 13:25:47.0

@Documented Annotation的使用:

@Documented Annotation的作用是在生成javadoc文档的时候将该Annotation也写入到文档中。

java 代码
  1. package com.test;   
  2.   
  3. import java.lang.annotation.Documented;   
  4.   
  5. @Documented  
  6. public @interface DocumentTest {   
  7.     String hello();   
  8. }   

 

java 代码
  1. package com.test;   
  2.   
  3.   
  4. public class DocumentClass {   
  5.     /**  
  6.      * this is method of doSomething  
  7.      */  
  8.     @DocumentTest(hello = "yahaitt")   
  9.     public void doSomething()   
  10.     {   
  11.         System.out.println("do something");   
  12.     }   
  13.        
  14.     /**  
  15.      * this is method of say  
  16.      */  
  17.     public void say()   
  18.     {   
  19.         System.out.println("say");   
  20.     }   
  21. }   

 

生成的doc文件中如下:

doSomething

@DocumentTest(hello="yahaitt")
public void doSomething()
this is method of doSomething
  相关解决方案