Reputation: 5361
In IntelliJ you can generate getter and setter methods for your Java class fields. The problem I have is that by our code conventions private fields need to start with an underscore, for example:
private String _name;
IntelliJ will generated the following getter and setter methods for this field:
public String get_reportName()
{
return _reportName;
}
public void set_reportName(String _reportName)
{
this._reportName = _reportName;
}
I would like it to rather generate:
public String getReportName()
{
return _reportName;
}
public void setReportName(String reportName)
{
_reportName = reportName;
}
Can I somehow customize the generation code to achieve this?
Thanks
Upvotes: 7
Views: 3280
Reputation: 11699
Open IntelliJ Preferences (Command + , on Mac).
Navigate through:
Editor
-- Code Style
---- Java
Select the Code Generation
tab. Under Name prefix:
put an underscore in the Field:
text box. Now, it should work for you. (At least in IntelliJ 15 where I tested this).
Upvotes: 14