简体   繁体   English

如何将Javadoc从变量复制到构造函数

[英]how to copy javadoc from variables to constructor

I am having some problems with Javadoc. 我有一些问题的Javadoc。 I have written documentation for variables of a class. 我为一类变量,书面文件。 And then I want to use that same javaDoc in the constructor. 然后,我想在构造函数中使用相同的javaDoc。 I didn't seem to be able to use @link or @see for this purpose (Well, Netbeans didn't show the result I liked). 我似乎无法为此目的使用@link@see (好吧,Netbeans没有显示我喜欢的结果)。

It seems like a hassle to copy-paste everything, so is there a tag/parameter to copy javaDoc? 复制粘贴所有内容似乎很麻烦,因此是否存在用于复制javaDoc的标记/参数?

Here is the example: 这是示例:

/**
 * The id for identifying this specific detectionloop. It is assumed the
 * Detectionloops are numbered in order, so Detectionloop '2' is always next to
 * Detectionloop '1'. 
 */
private int id;

/**
 * Constructor for a detectionloop. Detectionloops are real-world sensors
 * that register and identify a kart when it passes by. Please note that
 * this class is still under heavy development and the parameters of the
 * constructor may change along the way!
 *
 * @param id The id for identifying this specific detectionloop. It is assumed
 *    the Detectionloops are numbered in order, so Detectionloop '2' is always
 *    next to Detectionloop '1'. 
 * @param nextID The id of the next detectionloop is sequense.
 * @param distanceToNext The distance in meters to the next detectionloop.
 */
DetectionLoop(int id, int nextID, int distanceToNext) {
    this.distanceToNext = distanceToNext;
    this.id = id;
    if (Detectionloops.containsKey(id)) {
        throw new IllegalArgumentException("Detectionloop " + this.id
                + " already exist, please use a unused identification!");
    } else {
        Detectionloops.put(this.id, this);
    }
}

This is unfortunately impossible using standard Javadoc . 不幸的是,使用标准Javadoc是不可能的。 As a workaround, you could use the @link tag to reference the field, and then people could click the link to get at its documentation. 解决方法是,可以使用@link标记引用该字段,然后人们可以单击该链接以获取其文档。 This would require a click, but at least you don't have to maintain redundant documentation: 这将需要单击,但是至少您不必维护多余的文档:

/**
 * ...
 * @param id the value for {@link #id}

The only other way of solving this that I know of is to write a custom doclet, which would allow you to define your own tag for your purpose. 我知道解决此问题的另一种方法是编写自定义doclet,这将使您可以根据自己的目的定义自己的标签

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM