Javadoc a class 实现的外部接口不是您为其编写源代码的接口?
Javadoc a class implementing an external interface that isn't one you wrote the source for?
如果我的 class 从外部库(一个我没有写过的)实现了一个记录良好的外部接口,例如 javax.persistence
的 AttributeConverter
,我想知道记录我的重写方法的正确方法。我是使用 @inheritDoc 还是非 javadoc 注释块,或者根本不使用文档,因为文档很容易找到,正确的方法是什么?
这取决于你想做什么。您必须问自己的第一个问题是:我有什么要添加到 parents Javadoc 中的吗?
如果答案是 "no",这是一种基于意见的答案。如果您只是将其省略,那么只要您使用 @Override
,就会使用 parents Javadoc。 non-javadoc
注释对于结果变得无关紧要。它仍然在源代码中发挥作用。参见 Should I use a "non-Javadoc" comment?
@inheritDoc
在这种情况下不是那么有用,因为它只复制它所使用的元素。来自 documentation:
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.
如果您想向 parents 文档添加一些内容,它就会发挥作用。使用它在您自己的评论中的某个位置插入 parents 文档。
如果我的 class 从外部库(一个我没有写过的)实现了一个记录良好的外部接口,例如 javax.persistence
的 AttributeConverter
,我想知道记录我的重写方法的正确方法。我是使用 @inheritDoc 还是非 javadoc 注释块,或者根本不使用文档,因为文档很容易找到,正确的方法是什么?
这取决于你想做什么。您必须问自己的第一个问题是:我有什么要添加到 parents Javadoc 中的吗?
如果答案是 "no",这是一种基于意见的答案。如果您只是将其省略,那么只要您使用 @Override
,就会使用 parents Javadoc。 non-javadoc
注释对于结果变得无关紧要。它仍然在源代码中发挥作用。参见 Should I use a "non-Javadoc" comment?
@inheritDoc
在这种情况下不是那么有用,因为它只复制它所使用的元素。来自 documentation:
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.
如果您想向 parents 文档添加一些内容,它就会发挥作用。使用它在您自己的评论中的某个位置插入 parents 文档。