4

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!

Raedwald
  • 46,613
  • 43
  • 151
  • 237
midnite
  • 5,157
  • 7
  • 38
  • 52

1 Answers1

2

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(){}
Jk1
  • 11,233
  • 9
  • 54
  • 64
  • Thanks for answer. But `@see` is just having a link in the bubble. It is not good enough :-/ – midnite Sep 13 '13 at 19:09
  • 1
    I'm afraid there's nothing better in bare javadoc. Only {@inheritDoc} copies the entire description, but it only works for implemented or overriden methods. – Jk1 Sep 13 '13 at 19:12
  • OH yes!! The one i came across was `/* (non-Javadoc) * @see java.lang.Object#equals(java.lang.Object) */ @Override public boolean equals(Object obj) { ... }`. i have just tried that pattern for a while, and it seems only work for inherited methods, as you said. – midnite Sep 13 '13 at 19:21