Lombok中关于@Data的使用解析

public class TestB extends TestA {
private String name;
private int age;
public TestB() {
}
public String getName() {
return this .name;
}
public int getAge() {
return this .age;
}
public void setName(String name) {
this .name = name;
}
public void setAge( int age) {
this .age = age;
}
public boolean equals(Object o) {
if (o == this ) {
return true ;
} else if (!(o instanceof TestB)) {
return false ;
} else {
TestB other = (TestB)o;
if (!other.canEqual( this )) {
return false ;
} else {
// 注意这里,真的是只比较了当前类中的属性,并没有比较父类中的属性
Object this $name = this .getName();
Object other$name = other.getName();
if ( this $name == null ) {
if (other$name == null ) {
return this .getAge() == other.getAge();
}
} else if ( this $name.equals(other$name)) {
return this .getAge() == other.getAge();
}
return false ;
}
}
}
protected boolean canEqual(Object other) {
return other instanceof TestB;
}
public int hashCode() {
int PRIME = true ;
int result = 1 ;
Object $name = this .getName();
int result = result * 59 ($name == null ? 43 : $name.hashCode());
result = result * 59 this .getAge();
return result;
}
public String toString() {
return "TestB(name=" this .getName()   ", age=" this .getAge()   ")" ;
}

Original: https://www.cnblogs.com/ExMan/p/16386479.html
Author: ExplorerMan
Title: Lombok中关于@Data的使用解析

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/546290/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球