@Documented annotation in java

前端 未结 3 1272
陌清茗
陌清茗 2021-01-31 13:08

What\'s the purpose of @Documented annotation in java?

I saw the documentation, but could not get much from it. Can someone point out with the help of an cl

3条回答
  •  我在风中等你
    2021-01-31 13:43

    @Documented is a meta-annotation. You apply @Documented when defining an annotation, to ensure that classes using your annotation show this in their generated JavaDoc. I've not seen much use of it, but there is an example here. An earlier question suggests that it doesn't work automatically in Eclipse, but I've tested in Eclipse 3.6, and my annotations appear in the JavaDoc popups whether or not I attach the @Documented annotation to them.

    Here's an example from Spring, which ensures that transactional methods are marked as such in the JavaDoc:

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

提交回复
热议问题