使用lombok的实体类的equals方法是怎么被调用的?
java吧
全部回复
仅看楼主
level 1
import lombok.AllArgsConstructor;
import lombok.Data;
@Data
@AllArgsConstructor
public class StreamName {
private String app;
private String name;
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
StreamName other = (StreamName) obj;
if (app == null) {
if (other.app != null)
return false;
} else if (!app.equals(other.app))
return false;
if (name == null) {
if (other.name != null)
return false;
} else if (!name.equals(other.name))
return false;
return true;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((app == null) ? 0 : app.hashCode());
result = prime * result + ((name == null) ? 0 : name.hashCode());
return result;
}
}
2020年10月26日 01点10分 1
level 1
这个实体类中的equals方法没有任何显示的调用,甚至把equals方法注释掉了也没有任何的编译错误,但是在debug是这个方法竟然被调用了,而且注释掉后程序竟然无法
正确的
运行,简直看不懂了,请各位大神赐教
2020年10月26日 01点10分 2
level 10
弃用不行吗,这个框架功能鸡肋,侵入性强,真没看出哪点好。
2020年10月26日 04点10分 4
这是别人写的代码,我要想弃用首先得明白怎么回事
2020年10月26日 05点10分
1