LinkedHashSet 去重

@Override
public int hashCode() {
return this.getDeviceid().hashCode() + this.getTerminalcode().hashCode();
}

@Override
public boolean equals(Object obj) {
DevicePostmanPackColumnConfig obj1 = (DevicePostmanPackColumnConfig) obj;
if (obj1.getDeviceid().equals(this.getDeviceid())&&obj1.getTerminalcode().equals(this.terminalcode)){
return true;
}
return false;
}

for (int i = 0; i < 3; i++) {
DevicePostmanPackColumnConfig configEntity = new DevicePostmanPackColumnConfig();
configEntity.setDeviceid(1L);
configEntity.setTerminalcode("bb");
list.add(configEntity);
}
原文地址:https://www.cnblogs.com/zfzf1/p/10562883.html