gpt4 book ai didi

java - 如何将 javadoc 从变量复制到构造函数

转载 作者:行者123 更新时间:2023-12-01 14:35:33 25 4
gpt4 key购买 nike

我在使用 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);
}
}

最佳答案

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

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

据我所知,解决此问题的唯一其他方法是编写一个自定义 doclet,它允许您定义 your own tag为了您的目的。

关于java - 如何将 javadoc 从变量复制到构造函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16518226/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com