0

我在使用 Javadoc 时遇到了一些问题。我已经为类的变量编写了文档。然后我想在构造函数中使用相同的 javaDoc。我似乎无法使用@link@see用于此目的(嗯,Netbeans 没有显示我喜欢的结果)。

复制粘贴所有内容似乎很麻烦,那么是否有标签/参数可以复制 javaDoc?

这是示例:

/**
 * 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);
    }
}
4

1 回答 1

2

不幸的是,使用标准 Javadoc是不可能的。作为一种解决方法,您可以使用@link标签来引用该字段,然后人们可以单击链接以获取其文档。这将需要单击,但至少您不必维护冗余文档:

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

我所知道的解决这个问题的唯一其他方法是编写一个自定义 doclet,它允许您为自己的目的定义自己的标签

于 2013-05-20T19:31:39.657 回答