Can I modify how get/setters are formatted?
Answered
Ok, I am a fan of brevity, and I believe that accessors/mutators are most clear (read as: far less polluting) as follows:
public int getX() { return x; }
public void setX(int x) { this.x = x; }
public int getY() { return y; }
public void setY(int y) { this.y = y; }
public int getWidth() { return width; }
public void setWidth(int width) { this.width = width; }
public int getHeight() { return height; }
public void setHeight(int height) { this.height = height; }
....Other than set up a live template or macro to do this after the fact (regex to the rescue, not hard), can I configure the formatting of the generated getter/setter to be as above by default?
Thanks!
Please sign in to leave a comment.
You can create your own template for getters/setters:
Well......I thought I understood. I can't find this section within the settings.
Is your example a live template, or someplace that defines how the Generate-->getters/setters function works?
For example, if I go to RClick-->Generate...-->Getters/Setters (or whatever it is), and select 4 fields, will they all obey the template you show, or is this something I have to do by selecting the field and then somehow invoking a template?
Thanks
Please see https://www.jetbrains.com/help/idea/getter-and-setter-templates-dialog.html.