我有两个自己的注释,用于不同的字段和方法以及@Deprecated注释。但是,与@Deprecated注释不同,注释可以在带有描述的 Javadoc 注释中显示,我是否不可能用自己的注释来做到这一点。
小例子:
/**
* Sends "bar".
*
* @deprecated Use {@link #sendFooBar()} instead.
*/
@Deprecated
@MyAnnotation // I want to add a description to this annotation in the comment above
public void sendBar(){
System.out.prntln("bar");
}
Run Code Online (Sandbox Code Playgroud)
所以我的问题是我必须做什么,以便在评论本身中显示注释并提供评论。
我不能只是将它添加到评论中,因为它会被视为“错误的标签”。
澄清一下:我不想只在评论中显示 @ 符号。我知道该怎么做。
我想在 Javadoc 注释中包含类似于可用于@Deprecated注释的文档(描述)。
自理有注释@Documented,@Retention(RetentionPolicy.RUNTIME)并@Target({ElementType.METHOD, ElementType.FIELD})重视他们的注释。