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);
}
posted @ 2019-03-20 09:30  zfzf1  阅读(672)  评论(0编辑  收藏  举报