Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configure IntelliJ getter and setter code generation [duplicate]

I'm use to defining member variables that are private with a prefix 'm'. Example:

private boolean mDone;

The getter / setter would typically look like this:

public boolean getDone() }
  return mDone;
}

public void setDone(boolean done) {
  mDone = done;
}

The Intellij IDE does have a way of creating these getters/setters but it adds the 'm' prefix to the names of the getter/setter methods. Is there a way to prevent this?

like image 971
Johann Avatar asked Mar 08 '16 18:03

Johann


People also ask

How do I select all getters and setters in Intellij?

You can use ⌘N (macOS), or Alt+Insert (Windows/Linux) for the Generate menu and then select Constructor , Getter , Setter or Getter and Setter .

How can I beautify code in Intellij?

Go to Settings/Preferences | Editor | Code Style, select your programming language, and open the Wrapping and Braces tab. In the Keep when reformatting section, select the formatting rules which you want to ignore and deselect those which should be applied. Reformat your code ( Ctrl+Alt+L ).


1 Answers

On my IntelliJ 15.0.3, I can navigate to:

File -> Settings -> Editor -> Code Style -> Java -> Code Generation

and set "Name Prefix" as m in the Naming panel:

enter image description here

like image 113
Konstantin Yovkov Avatar answered Oct 02 '22 20:10

Konstantin Yovkov