How can a method's Javadoc be copied into other method's Javadoc?

前端 未结 2 347
情书的邮戳
情书的邮戳 2021-01-01 10:28

I know that there is @inheritDoc, but it\'s only for methods which override others.

I have several classes with many delegate methods (

相关标签:
2条回答
  • 2021-01-01 11:15

    Sometimes it's actually a good thing to cut and paste documentation. 'Linking' documentation in some way, especially when there isn't in inheritance relationship, runs the risk that one of the methods will have it's behaviour changed somehow, making the linked documentation no longer valid.

    However in the case of delegates I've had the same problem a number of times. Usually you have a public method on a main class delegating to a package-private delegate, which has exactly the same behaviour as the main method. Here the solution is simple - document the main class, and put the @link or @see on the delegate class. Everybody can see the main class' documentation. You will probably need to have more detailed documentation, such as implementation details, on the delegate class too.

    0 讨论(0)
  • 2021-01-01 11:26

    A @link or @see tag would be appropriate here. If you're wrapping the method, it must provide distinctive behavior which makes it unsuitable for overloading or otherwise.

    0 讨论(0)
提交回复
热议问题