简体   繁体   中英

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

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!

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(){}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM