tags:

views:

360

answers:

3

Using Javadoc 1.5, I have been unable to create a @link to an Enumeration value.

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:

{@link Planet.EARTH}

I have tried the {@link Planet#EARTH} style too, but to no avail.

Anyone know if this is doable at all?

+2  A: 

I'm using Eclipse to check this, but

{@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. Still, maybe @see does the trick for you.

sfussenegger
+3  A: 

The # style works for me:

{@link Planet#EARTH}

The key is that the Planet package must be imported, or planet must be fully qualified - i.e.:

{@link com.something.somethingelse.Plane#EARTH}
aperkins
As sfussenegger noted, Eclipse handles the import for you.
aperkins
Thanks both answers helpful! I did get it to work using the fully qualified reference. Sometimes the compiler output isn't really helpful in determining what the problem is...
Christer Fahlgren
A: 

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).

But yes, Eclipse can take care of it all and standard

{@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).

Jack