Tuesday, 28 February 2017

HOW TO GENERATE GETTERS & SETTERS (Actuators & Mutators) FOR A POJO IN IntelliJ IDEA IDE?

For those, who are new to IntelliJ IDE, this article helps in generating Getters & Setters of any POJO (Plain Old Java Object).

First way: Keyboard Shortcut 

               On Mac ( command + N )
               On Linux & Windows — use (Alt + Insert)

The following screenshots works for Mac. The above keyboard shortcuts still works better on respective OS.

Step 1:

Create a simple POJO with some fields:

package sample;

/**
* Created by dineshdontha on 2/27/17.
*/
public class Person {

    String name;
    String password;
    Integer code;
    String city;

}

Step 2:

Press Command + N to see a context menu like this


Step 3:

You will see a popup as below, for selecting the fields:


Step4:

Select the required fields 



Second Way: 

Use the Menu : Code -> Generate . . .



Once after selecting Generate . . . Menu Item, the a context menu appears, just like in Step 2 as above & then everything is same.

                       HOPE IT IS HELPFUL...PLEASE SHARE THIS

No comments:

Post a Comment