Question

Eclipse have an option of generating getters and setters from respective variables. Is there an option or settings by which I can also generate the comments for getters and setters?

e.g. If my variable name is

protected boolean isActive;

Then while I generate getter for this, can I also get the auto generated comment block like this -

/**
 * Gets the value of the isActive property.
 * 
 * @return
 *     possible object is
 *     {@link Boolean }
 *     
 */
public Boolean getIsActive() {
    return isActive;
}

Would be great if this thing is possible. Also is that comment block customizable?

Was it helpful?

Solution

Go to Preferences>Java>Code Style>Code Templates and then change the Comments>Getters template. You also want to make sure the 'Automatically add comments for new methods and types' checkbox is selected.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top