JavaDoc: Reduce redundancy for Repeated Method Descriptions within the Same Class

302 views Asked by At

For example, i have two methods, public Tree<T> addChild(final T data) {} and public Tree<T> addChild(final T... data) {}, their JavaDocs are identical. How to put the /** method description */ in one of them, and use a tag to refer another JavaDoc to the previous one?

Just like, in concept:

/**
 * method description
 */
public Tree<T> addChild(final T data) { ... }

/**
 * @theTag #addChild(Object)
 */
public Tree<T> addChild(final T... data) { ... }

If i remember it correctly, i once accidentally came across a tag, which imports the entire method description of a Java native API method. So, it should be possible.

What is @theTag? Thanks very much!

1

There are 1 answers

3
Jk1 On

How's about @see tag? It's not quite importing, but rather placing a reference:

/**
 * action 1 description
 */
public void action1(){}

/**
 * @see MyClass#action1
 */
public void action2(){}