实体类
@Data
public class SmPersonSinceGrandOpen {
/** 跑批日期 */
private String workdateSm;
/** 统计维度(年龄段/家庭) 0:年龄段,1:家庭非家庭 */
private String dimStatsSm;
/** 维度详情 18岁以下/18-25岁/26-35岁/36-45/46-50岁/51岁及以上/家庭/非家庭 */
private String dimDetailSm;
/** 人数 */
private String personNumSm;
/** 占比 */
private String percentSm;
}
比较代码
List<SmPersonSinceGrandOpen> sms = new ArrayList<SmPersonSinceGrandOpen>(){{
SmPersonSinceGrandOpen sm1 = new SmPersonSinceGrandOpen();
sm1.setWorkdateSm("1");
sm1.setDimStatsSm("1");
sm1.setDimDetailSm("1");
sm1.setPersonNumSm("1");
sm1.setPercentSm("1");
add(sm1);
SmPersonSinceGrandOpen sm2 = new SmPersonSinceGrandOpen();
sm2.setWorkdateSm("2");
sm2.setDimStatsSm("2");
sm2.setDimDetailSm("2");
sm2.setPersonNumSm("2");
sm2.setPercentSm("2");
add(sm2);
}};
List<SmPersonSinceGrandOpen> sms1 = new ArrayList<SmPersonSinceGrandOpen>(){{
SmPersonSinceGrandOpen sm1 = new SmPersonSinceGrandOpen();
sm1.setWorkdateSm("1");
sm1.setDimStatsSm("1");
sm1.setDimDetailSm("1");
sm1.setPersonNumSm("1");
sm1.setPercentSm("1");
add(sm1);
SmPersonSinceGrandOpen sm2 = new SmPersonSinceGrandOpen();
sm2.setWorkdateSm("2");
sm2.setDimStatsSm("2");
sm2.setDimDetailSm("2");
sm2.setPersonNumSm("2");
sm2.setPercentSm("2");
add(sm2);
/* SmPersonSinceGrandOpen sm3 = new SmPersonSinceGrandOpen();
sm3.setWorkdateSm("3");
sm3.setDimStatsSm("3");
sm3.setDimDetailSm("3");
sm3.setPersonNumSm("3");
sm3.setPercentSm("3");
add(sm3);*/
}};
sms.sort(Comparator.comparingLong(SmPersonSinceGrandOpen::hashCode));
sms1.sort(Comparator.comparingLong(SmPersonSinceGrandOpen::hashCode));
System.out.println(sms.toString().equals(sms1.toString()));