我在使用“@link”和“@see”标签为内部/嵌套类的构造函数工作时遇到了问题,并希望这里有人能够提供帮助。这个简短的示例类给出了第25行的javadoc警告,在“Layer()”文档的前面几行中引用了“@link”和(等价的)“@see”标签。内部/嵌套类构造函数的正确“@link”或“@see”javadoc标记是什么?
package bogus;
import javax.swing.JPanel;
public class LayeredPlot extends JPanel {
/**
* Constructor for the plot.
*/
public LayeredPlot() {
}
public static class Layer {
private String name;
/**
* Construct a default layer with a default name. This method calls
* {@link LayeredPlot.Layer#Layer(String)} OR calls == JAVADOC WARNING
* {@link #Layer(String)} OR calls == JAVADOC WARNING
* {@link Layer#Layer(String)} == JAVADOC WARNING
* with a null name to perform the construction.
* The constructor for the layer can be found
* {@link LayeredPlot#LayeredPlot() here}. == JAVADOC Okay!
*
* @see LayeredPlot.Layer#Layer(String) == JAVADOC WARNING
* @see #Layer(String) == JAVADOC WARNING
* @see Layer#Layer(String) == JAVADOC WARNING
* @see LayeredPlot#LayeredPlot() == JAVADOC Okay!
*/
public Layer() { // Line 25: javadoc warnings reference this line
this(null);
}
/**
* Construct a layer with the specified name.
*
* @param name The desired name for the layer within the plot.
*/
public Layer(String name) {
this.name = name;
}
}
}
的警告(3 “@see”,3 “@link”)都说:can't find Layer(String) in bogus.LayeredPlot.Layer
。
请注意:所有其他javadoc按预期工作(包括内部类方法和本示例中对LayeredPlot本身的构造函数的引用)。
任何关于内部/嵌套类构造函数的正确javadoc标签的建议将不胜感激。
谢谢。
我没有答案,但我只是想知道:文档注释通常用于记录您的API,即告诉客户如何使用您的模块。那么,为什么你要记录如此多的执行情况?这是一个为继承设计的类吗? – scottb
这里的评论仅作为示例。对我而言,重要的是外部和内部的班级都是公开的,因此值得评论。 – skuzmo
只是术语,但我会说你没有内在的课堂。你的嵌套类是一个静态成员类,并且通过不依赖于封闭类的任何实例而区别于*内部类*。在几乎所有重要的方面,一个静态成员类的行为就像一个顶级类。 – scottb