更改继承的javadoc [英] Changing inherited javadoc

查看:79
本文介绍了更改继承的javadoc的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个子类,并且在添加文档时,我想为我不变的方法添加细节.更具体地说,我继承了List<>.并且它仅包含某些其他方法调用之后的项目,我想在继承的方法(例如get())的描述中添加一个细节.最好是,我想不用执行以下操作:

I''m writing a subclass and while adding documentation, I would like to add detail to a method which I''m not changing. More specifically, I''m inheriting a List<> and it only contains items after certain other method calls, a detail I would like to add to the description of inherited methods such as get(). Preferrably, I would like to do this without something like the following:

/**
*Updated description
*/
public int get(int n)
{
    return super.get(n)
}



Google未能使我找到答案.

在此先感谢您.



Google has failed me in finding an answer to this.

Thanks in advance.

推荐答案

我有种可怕的感觉,您被困在一块岩石和一块硬土地之间.

如果您不重写基类的方法,那么我将看不到如何摆弄他们的Javadoc.考虑一下我从基类B派生两个子类D和E的情况.B.x()都被继承,并且具有Javadoc.但是,我希望D.x()的Javadoc告诉我D处理偶数整数.我也希望E.x()告诉我E使用奇数整数.

如果您想装饰派生类中的Javadoc,我唯一能看到的解决方案就是您的代码片段.根据该方法完成的工作量,可以接受另一级方法调用的开销.

顺便说一句,感谢您发人深省的问题!

干杯,
彼得
I have a horrible feeling that you''re stuck between a rock and a hard place.

If you don''t override the methods of your base class, I can''t see how you can fiddle with their Javadoc. Consider the case where I derive two subclasses D and E from base class B. B.x() in inherited by both, and has Javadoc. However, I want the Javadoc of D.x() to tell me that D deals with even integers. I want E.x() likewise to tell me that E works with odd integers.

If you want to decorate the Javadoc in the derived class, the only solution I can see is as in your code snippet. Depending on how much work the method does, the overhead of another level of method call may be acceptable.

btw, thanks for a thought-provoking and well-expressed question!

Cheers,
Peter


这篇关于更改继承的javadoc的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆