Reputation: 39
One topic that I can't seem to find information on is how to do Javadoc for enums that have an extra parameter. For example in the classic Coins example how can the 1,5,10,25 values be associated with penny, nickle, dime, quarter (other that keying each in by hand)?
enum Coin {
PENNY(1),
NICKEL(5),
DIME(10),
QUARTER(25);
private final int denomValue;
Coin(int denomValue) {
this.denomValue = denomValue;
}
int denomValue() {
return denomValue;
}
int toDenomination(int numPennies) {
return numPennies / denomValue;
}
}
A typical use case is documenting error mnemonics and int error codes.
Upvotes: 2
Views: 449
Reputation: 4819
Won't this work for you or am I misunderstanding the question?
/**
* blah blah
*/
enum Coin {
/**
* Penny - 1 cent, blah blah
*/
PENNY(1),
/**
* Nickel - 5 cents, blah blah
*/
NICKEL(5),
...
Upvotes: 0