Reputation: 829
I'm using Eclipse. I want the comments made in the overridden method to appear instead.
Here's an example -
enum Foo{
ITEM{
/**
* Arguments must be received in the following order...
*/
@Override
void bar(String[] args){...}
};
/**
* Bars the specific args
* @param args the specific args
*/
abstract void bar(String[] arags);
}
When I have something like the following Foo.ITEM.bar(...)
and I hover over it, I want to read
Bars the specific args
Arguments must be received in the following order...
@args the specific args
Is this possible?
Upvotes: 2
Views: 2688
Reputation: 12776
If I understand what you want correctly, this is what {@inheritDoc}
is for. Place it in the comment body or appropriate tag to get the comment from the superclass/interface declaration.
Source and relevant excerpt:
Automatic Copying of Method Comments The Javadoc tool has the ability to copy or "inherit" method comments in classes and interfaces under the following two circumstances. Constructors, fields and nested classes do not inherit doc comments.
Automatically inherit comment to fill in missing text - When a main description, or @return, @param or @throws tag is missing from a method comment, the Javadoc tool copies the corresponding main description or tag comment from the method it overrides or implements (if any), according to the algorithm below. More specifically, when a @param tag for a particular parameter is missing, then the comment for that parameter is copied from the method further up the inheritance hierarchy. When a @throws tag for a particular exception is missing, the @throws tag is copied only if that exception is declared.
This behavior contrasts with version 1.3 and earlier, where the presence of any main description or tag would prevent all comments from being inherited.
Explicitly inherit comment with {@inheritDoc} tag - Insert the inline tag {@inheritDoc} in a method main description or @return, @param or @throws tag comment -- the corresponding inherited main description or tag comment is copied into that spot.
Upvotes: 2
Reputation: 74800
I don't think you can really have Javadocs for individual enum constants' methods.
So, either put the important information into the general method (i.e. Foo.bar
), or into the documentation of the individual constant (i.e. Foo.ITEM
). The methods for the individual constants shouldn't be that different that they require individual comments anyways.
Upvotes: 1
Reputation: 2509
If it's an interface, add the javadoc to the interface, and then use the @Override tag, and it should show up.
Upvotes: 1