IDEA之lombok插件
Java 实体类自动生成get set!
1.idea Ctrl+Alt+S 先配置上lombok插件,如图:
2.pom.xml中引入依赖,如图:
3.实体类上添加@Data,如图:
4.看.class文件,get set toString 方法都会有。
package com.example.domain;
public class Users {
private String id;
private String name;
private String age;
public Users() {
}
public String getId() {
return this.id;
}
public String getName() {
return this.name;
}
public String getAge() {
return this.age;
}
public void setId(String id) {
this.id = id;
}
public void setName(String name) {
this.name = name;
}
public void setAge(String age) {
this.age = age;
}
public boolean equals(Object o) {
if (o == this) {
return true;
} else if (!(o instanceof Users)) {
return false;
} else {
Users other = (Users)o;
if (!other.canEqual(this)) {
return false;
} else {
label47: {
Object this$id = this.getId();
Object other$id = other.getId();
if (this$id == null) {
if (other$id == null) {
break label47;
}
} else if (this$id.equals(other$id)) {
break label47;
}
return false;
}
Object this$name = this.getName();
Object other$name = other.getName();
if (this$name == null) {
if (other$name != null) {
return false;
}
} else if (!this$name.equals(other$name)) {
return false;
}
Object this$age = this.getAge();
Object other$age = other.getAge();
if (this$age == null) {
if (other$age != null) {
return false;
}
} else if (!this$age.equals(other$age)) {
return false;
}
return true;
}
}
}
protected boolean canEqual(Object other) {
return other instanceof Users;
}
public int hashCode() {
int PRIME = true;
int result = 1;
Object $id = this.getId();
int result = result * 59 + ($id == null ? 43 : $id.hashCode());
Object $name = this.getName();
result = result * 59 + ($name == null ? 43 : $name.hashCode());
Object $age = this.getAge();
result = result * 59 + ($age == null ? 43 : $age.hashCode());
return result;
}
public String toString() {
return "Users(id=" + this.getId() + ", name=" + this.getName() + ", age=" + this.getAge() + ")";
}
}
还没有评论,来说两句吧...