[英]How to @link to a Enum Value using Javadoc
Using Javadoc 1.5, I have been unable to create a @link to an Enumeration value. 使用Javadoc 1.5,我无法创建枚举值的@link。
What I would like to do is to create an Enum like this: 我想做的是创建一个这样的枚举:
public enum Planet {
/**
* MERCURY is a fun place.
*/
MERCURY,
/**
* VENUS is more fun.
*/
VENUS,
/**
* But nothing beats the Earth.
*/
EARTH,
/**
* Others we know nothing about.
*/
OTHERS
}
And then refer to the Javadoc for Earth using a link like this: 然后使用以下链接引用Javadoc for Earth:
{@link Planet.EARTH}
I have tried the {@link Planet#EARTH}
style too, but to no avail. 我也尝试过{@link Planet#EARTH}
风格,但无济于事。
Anyone know if this is doable at all? 有谁知道这是否可行?
The # style works for me: #style对我有用:
{@link Planet#EARTH}
The key is that the Planet package must be imported, or planet must be fully qualified - ie: 关键是必须导入Planet包,否则行星必须完全合格 - 即:
{@link com.something.somethingelse.Planet#EARTH}
I'm using Eclipse to check this, but 我正在使用Eclipse来检查这个,但是
{@link Planet#EARTH}
style seems to work. 风格似乎有效。 However, I normally prefer 但是,我通常更喜欢
@see Planet#EARTH
anyway. 无论如何。 Not sure what Eclipse uses to generate Javadoc, but I'm using JDK6. 不确定Eclipse使用什么来生成Javadoc,但我使用的是JDK6。 Still, maybe @see does the trick for you. 不过,也许@see为你做了诀窍。
As long as it's imported you can link it (but when you do this, IMO it makes the imports messy- what ones are used in code and what ones in javadoc? I like to just use the fully qualified name). 只要它被导入就可以链接它(但是当你这样做时,IMO会让导入变得混乱 - 代码中使用的是什么以及javadoc中的内容是什么?我喜欢使用完全限定的名称)。
But yes, Eclipse can take care of it all and standard 但是,是的,Eclipse可以照顾一切和标准
{@link Planet#EARTH}
works fine. 工作良好。
If your using Eclipse, Ctrl + Shift + O (on PC) or Cmd + Shift + O (on Mac) auto-adjust your imports (this means if you have extra imports not being used, they're removed, as well as adding any imports you need). 如果您使用Eclipse,Ctrl + Shift + O(在PC上)或Cmd + Shift + O(在Mac上)自动调整您的导入(这意味着如果您没有使用额外的导入,它们将被删除,以及添加您需要的任何进口)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.