When the project was developed, it was found that the original project code entity class had no attributes in the getter and setter
The code in the project is this stuff.
public class DingDingDepartMentV0 {
private static final long serialversionuid = -584794972336877603l;
Department ID
private Long ID;
Parent Department ID
Private Long parentid;
Department name
Private String name;
When a group has been created, whether a new person joins the department will automatically join the group, True indicates that, false is not
private Boolean autoadduser;
Whether to synchronize the creation of an enterprise group that associates this department, true indicates yes, false means not
private Boolean createdeptgroup;
However, when the object is instantiated, it is also found that the methods are called
Partytype Partytype = new Partytype ();
Partytype.setid (Dingdingdepartmentvo.getid ());
Partytype.setname (Dingdingdepartmentvo.getname ());
I do not understand, and then there are predecessors told me-– "Lombok"
So it's just a little bit of data to look at, Lombok is designed to eliminate the need for a lot of redundant code when creating entity classes, to look at specific cases:
No use of Lombok:
public class Student {private Integer ID;
Private String StudentID;
Private String Studentname;
private String password;
private Integer grade;
Private String Studenttabcol;
Private Date Unusedbegintime;
Public Integer GetId () {return id;
The public void SetId (Integer id) {this.id = ID;
Public String Getstudentid () {return studentid;
} public void Setstudentid (String studentid) {This.studentid = StudentID = = null? Null:studentid.trim ();
Public String Getstudentname () {return studentname; } public void Setstudentname (String studentname) {this.studentname = Studentname = = null? null:studentnam
E.trim ();
Public String GetPassword () {return password;
} public void SetPassword (String password) {this.password = password = = null? Null:password.trim (); Public Integer Getgrade () {return gradE
The public void Setgrade (Integer grade) {This.grade = grade;
Public String Getstudenttabcol () {return studenttabcol; } public void Setstudenttabcol (String studenttabcol) {This.studenttabcol = Studenttabcol = = null? null:st
Udenttabcol.trim ();
Public Date Getunusedbegintime () {return unusedbegintime;
The public void Setunusedbegintime (Date unusedbegintime) {this.unusedbegintime = Unusedbegintime; @Override public String toString () {return "student{" + "id=" + ID + " , studentid= ' "+ studentid + ' \ ' +", studentname= ' "+ studentname + ' \ ' +", password= '
"+ password + ' +", grade= "+ Grade +", studenttabcol= ' "+ studenttabcol + ' \" +
", unusedbegintime=" + Unusedbegintime + '} '; }
}
This is the case using the Lombok:
@Data
@NoArgsConstructor
@AllArgsConstructor public
class Student {
private Integer ID;
Private String StudentID;
Private String studentname;
private String password;
private Integer grade;
Private String Studenttabcol;
Private Date unusedbegintime;
}
Believe that you do not have to say anything, you can see the difference between two kinds.
@Data This annotation can automatically create the methods of Get, set, ToString, Eaquls, hashcode, etc.
@NoArgsConstructor This is a parameterless constructor
@AllArgsConstructor Full parameter constructor
@Setter Set method
@Getter Get method
Of course there are some specific usage and detailed questions can refer to the official website, here is a small video, speak very good
Tip: Install Lombok plug-ins in IJ
First download Lombok of the dependency package, the official website will be able to download directly
If it's maven, add dependencies in Pom.xml
<dependency>
<groupId>org.projectlombok</groupId>
<artifactid>lombok</ artifactid>
<version>1.14.4</version>
</dependency>
Then try to load the plugin in IJ:
Find Preference
Then select Plugins, enter Lombok, if not, select the button in the middle below to automatically install
The next can be practical, of course, this method is not necessarily better than the traditional, I hope to understand the Lombok users have a little help