1

Is there a way to write a javadoc comment for both an accessor and a mutator (getter/setter), to avoid duplicating information about the field underlying the method?

e.g.:

private float value;

/**
 * This value represents something.
 */
public float getValue () {
    return value;
}

/**
 * This value represents something.
 * @param    _value    A new value.
 */
public float setValue (float _value) {
    value = _value;
}

Seems inefficient and error-prone to duplicate information about the 'value' field in the javadocs for getter and setter....

ericsoco
  • 24,913
  • 29
  • 97
  • 127
  • 1
    There is some discussion on this topic [here](http://stackoverflow.com/questions/1028967/simple-getter-setter-comments). – Beau Grantham Dec 22 '11 at 22:04
  • thanks beau. figured this had been asked before but couldn't find it. i voted to close my question. – ericsoco Dec 27 '11 at 22:59

1 Answers1

3

You can use the @see tag to point from the documentation of one method to the other like this:

@see # setValue (float)

Eclipse will help provide code completion for javadoc as well to make it easy to create the comments.

For details, @see http://docs.oracle.com/javase/1.5.0/docs/tooldocs/windows/javadoc.html#@see

centic
  • 15,565
  • 9
  • 68
  • 125