Javadoc inheriting parent constructors documentati

2020-03-09 07:38发布

Consider that I am extending a class such as:

public class MyComboBox<T> extends JComboBox<T> {

    public MyComboBox() {
        super();
    }

    public MyComboBox(ComboBoxModel<T> model ) {
        super(model);
    }

}

Re-defining the parent's constructors (which are fitting for my new class, of course) is annoying enough, but to also copy each constructors documentation is even worse. Not to mention that it's bad for further inheritance, since I now have to update the documentation multiple times.

Obviously, {@inheritDoc} won't work as I am not overriding anything. This is, however, the behavior I'm looking for. Is there any way to achieve this?

How to inherit the parent constructors documentation?

3条回答
Explosion°爆炸
2楼-- · 2020-03-09 08:12

Use the @see tag and put the class & member name. To see how that shows up look at JDocs where you can jump from javadoc to source code.

The exact synatax is:

 @see com.x.y.z.ClassName#methodName()
查看更多
乱世女痞
3楼-- · 2020-03-09 08:13

You can not override constructors, therefore there is no need to propagate javadocs. Just explain what the client of your object needs to know about how that particular constructor would contruct the object. If it just passes construction on to an extended object, then say just that.

查看更多
啃猪蹄的小仙女
4楼-- · 2020-03-09 08:16

We do have a super class constructor even in Java 7.

String class has reference to its super class Object

http://docs.oracle.com/javase/8/docs/api/

查看更多
登录 后发表回答