Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Append new JavaDoc to existing ones from the super method

I have generated an Interface which is very well documented. Every method does have his own JavaDoc. The clases which implement this Interface can have little differents in their logic.

How can i add JavaDoc to the existing JavaDoc from the super class. The key word

/**
 * {@inheritDoc}
 */

only set the javaDoc of the super class to the current method. But when i try to add some words, the JavaDoc of the super method is gone, like

/**
 * {@inheritDoc}
 * These value depends on...
 */

Does anybody have a idea how i can update the JavaDoc of a super method, without deleting.

EDIT:

Regarding to Brian Agnew answer, which is good but not a real answer ;)

You also can have the same problem when you want to overwrite an existing method, like paint() in Swing, and want to describ how to initialize or handle the draw behaviour from outside. This is not only for interface description.

like image 257
Markus Lausberg Avatar asked Apr 02 '09 13:04

Markus Lausberg


People also ask

How do you add a Javadoc code?

Place the caret at the declaration in the editor, press Alt+Enter , and select Add Javadoc from the list.

Why is super super not allowed Java?

super. method() not allowed in Java?” Because it violates encapsulation. Encapsulation is a principle of wrapping code and data(variables) together into a single unit.

Can we use super super in Java?

The super keyword in Java is a reference variable that is used to refer parent class objects. The super() in Java is a reference variable that is used to refer parent class constructors. super can be used to call parent class' variables and methods. super() can be used to call parent class' constructors only.

How do you call a super class method?

To call methods of the superclass that is overridden in the subclass. To access attributes (fields) of the superclass if both superclass and subclass have attributes with the same name. To explicitly call superclass no-arg (default) or parameterized constructor from the subclass constructor.


2 Answers

I guess that when you need to add something to javadoc, you changed something. So maybe it will be correct to write javadoc in exactly same way.

/**
 * Enhanced swing paint for my cool component.
 * @see JButton#paint();
 */
@Override
public void paint() {
    super.paint();
    //my stuff
}
like image 130
pnemec Avatar answered Oct 09 '22 20:10

pnemec


I don't know any direct JavaDoc idiom that does that. However Eclipse and IntelliJ will let you grab the super JDoc and insert it... it's far from perfect, as if you change the supr JDoc you will have to reedit all the overrides, but it's better than copy-paste by hand...

like image 2
Varkhan Avatar answered Oct 09 '22 19:10

Varkhan