版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/dreamzuora/article/details/88630560
public class Contract {
private String contractId;
private String contractName;
private Date begin;
private Date end;
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Contract contract = (Contract) o;
//自己的判断条件是时间段重合的算做同一个对象
return false;
}
@Override
public int hashCode() {
//通过Objects类提供的hash方法
int hash = Objects.hash(contractId, contractName);
return hash;
}
转载:https://www.cnblogs.com/sansamh/p/9025030.html