I use the Generate function in the context menu to create my getter and setter methods. But there seems no way to tell Intellij to place the generated methods after the last method in the file ie at the bottom of the class definition. This is possible in Eclipse. Anybody know how to do it automatically in Intellij?
The getter and setter method names are generated by IntelliJ IDEA according to your code generation naming preferences. On the Code menu, click Generate Alt+Insert. In the Generate popup, click one of the following:
Getter and Setter to generate both accessor and mutator methods. Select the fields to generate getters or setters for and click OK. You can add a custom getter or setter method by clicking and accessing the Getter/Setter Templates dialog. If a field is not in the list, then the corresponding getter and setter methods are already defined for it.
Now, you can access the fullname setter and getter like a regular class property: Use TypeScript getters/setters to control the access properties of a class. The getter/setters are also known as accessors/mutators.
IntelliJ IDEA can generate accessor and mutator methods ( getters and setters) for the fields in your classes. Generated methods have only one argument, as required by the JavaBeans API. The getter and setter method names are generated by IntelliJ IDEA according to your code generation naming preferences.
If you want to generate getters and setters via Generate menu, the only way is to place cursor at the bottom of your class (or wherever you want them to be)
But if your field is not used yet, there is another option: navigate to the field you need getter/setter for, press Alt+Enter (it calls intentions dialog) and choose "generate getter and setter" option. Then getter and setter will be generated at the bottom of the class (but not below inner classes if any).
First of all a little hint. IntelliJ is designed to use without a mouse, so I prefer using the keyboard-shortcut Alt + Insert for code generating.
I don't know any possibility to generally define the place for inserting generated code. I recommend to place the cursor there, where you want to insert generated code and then generate it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With