标签:return name age Object other 注解 Data public
简介
对于 Data 注解基本理解而言就是生成 getter & setter 函数
但是经过探究
不单单有getter & setter 还有 toString方法 hashCode 方法 和 equals 方法。
原代码
import lombok.Data;
@Data
public class TestDTO {
private Integer age;
private String name;
}
编译后的代码
public class TestDTO {
private Integer age;
private String name;
public TestDTO() {
}
public Integer getAge() {
return this.age;
}
public String getName() {
return this.name;
}
public void setAge(final Integer age) {
this.age = age;
}
public void setName(final String name) {
this.name = name;
}
public boolean equals(final Object o) {
if (o == this) {
return true;
} else if (!(o instanceof TestDTO)) {
return false;
} else {
TestDTO other = (TestDTO)o;
if (!other.canEqual(this)) {
return false;
} else {
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;
}
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;
}
return true;
}
}
}
protected boolean canEqual(final Object other) {
return other instanceof TestDTO;
}
public int hashCode() {
int PRIME = true;
int result = 1;
Object $age = this.getAge();
int result = result * 59 + ($age == null ? 43 : $age.hashCode());
Object $name = this.getName();
result = result * 59 + ($name == null ? 43 : $name.hashCode());
return result;
}
public String toString() {
return "TestDTO(age=" + this.getAge() + ", name=" + this.getName() + ")";
}
}
标签:return,name,age,Object,other,注解,Data,public 来源: https://www.cnblogs.com/eat-too-much/p/16586735.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。