2个不同的对象集合如何取交集和差集,vmware10虚拟机使用教程

2个不同的对象集合如何取交集和差集,vmware10虚拟机使用教程,第1张

2个不同的对象集合如何取交集和差集,vmware10虚拟机使用教程
  • 产品类型

*/

private String product_type;

private String function_id;

private Integer sent;

@DateTimeFormat(pattern=“yyyy-MM-dd HH:mm:ss”)

@JsonFormat(timezone = “GMT+8”,pattern = “yyyy-MM-dd HH:mm:ss”)

//@com.fasterxml.jackson.annotation.JsonIgnore

private Date create_time;

@DateTimeFormat(pattern=“yyyy-MM-dd HH:mm:ss”)

@JsonFormat(timezone = “GMT+8”,pattern = “yyyy-MM-dd HH:mm:ss”)

// @com.fasterxml.jackson.annotation.JsonIgnore

private Date update_time;

private Integer is_delete;

public TbHuidou() {

}

@Override

public boolean equals(Object o) {

if (this == o) return true;

if (o == null || getClass() != o.getClass()) return false;

TbHuidou tbHuidou = (TbHuidou) o;

return dzh_no.equals(tbHuidou.dzh_no) && lc_no.equals(tbHuidou.lc_no) && product_code.equals(tbHuidou.product_code) && function_id.equals(tb

【一线大厂Java面试题解析+后端开发学习笔记+最新架构讲解视频+实战项目源码讲义】

浏览器打开:qq.cn.hn/FTf 免费领取

Huidou.function_id);

}

@Override

public int hashCode() {

final int prime = 31;

int result = 17;

result = prime * result + (dzh_no == null ? 0 : dzh_no.hashCode());

result = prime * result + (lc_no == null ? 0 : lc_no.hashCode());

result = prime * result + (product_code == null ? 0 : product_code.hashCode());

result = prime * result + (function_id == null ? 0 : function_id.hashCode());

return result;

}

TrequestHuiDouVo

private String vc_custno;

private String vc_combcode;

private String vc_fundcode;

取交集代码 tbHuidous数据不能重复 否则需要先去重复

public static void main(String[] args) {

List tbHuidous = new ArrayList<>();

TbHuidou tbHuidou = new TbHuidou();

tbHuidou.setCf_no(“1”);

tbHuidou.setDzh_no(“1”);

tbHuidou.setLc_no(“1”);

tbHuidou.setProduct_code(“1”);

tbHuidou.setFunction_id(“1”);

tbHuidou.setProduct_type(“1”);

tbHuidous.add(tbHuidou);

TbHuidou tbHuidou2 = new TbHuidou();

tbHuidou2.setCf_no(“2”);

tbHuidou2.setDzh_no(“2”);

tbHuidou2.setLc_no(“2”);

tbHuidou2.setProduct_code(“2”);

tbHuidou2.setFunction_id(“2”);

tbHuidou2.setProduct_type(“2”);

tbHuidous.add(tbHuidou2);

List list = new ArrayList<>();

TrequestHuiDouVo trequestHuiDouVo = new TrequestHuiDouVo();

trequestHuiDouVo.setVc_custno(“1”);

trequestHuiDouVo.setVc_fundcode(“1”);

list.add(trequestHuiDouVo);

TrequestHuiDouVo trequestHuiDouVo2 = new TrequestHuiDouVo();

trequestHuiDouVo2.setVc_custno(“2”);

trequestHuiDouVo2.setVc_combcode(“2”);

list.add(trequestHuiDouVo2);

TrequestHuiDouVo trequestHuiDouVo3 = new TrequestHuiDouVo();

trequestHuiDouVo3.setVc_custno(“7”);

trequestHuiDouVo3.setVc_combcode(“7”);

list.add(trequestHuiDouVo3);

List list3 = tbHuidous.stream().filter(one -> {

List result = list.stream().map(two -> {

if (one.getProduct_type().equals(“1”) && one.getLc_no().equals(two.getVc_custno()) && one.getProduct_code().equals(two.getVc_fundcode())){

return true;

}else if (one.getProduct_type().equals(“2”) && one.getLc_no().equals(two.getVc_custno()) && one.getProduct_code().equals(two.getVc_combcode())){

return true;

}else {

return false;

}

// return one == two;

}).collect(Collectors.toList());

if (result.indexOf(true) > -1)

return true;

return false;

}).collect(Collectors.toList());

list3.stream().forEach(System.out::println);

}

取差集代码

public static void main(String[] args) {

List tbHuidous = new ArrayList<>();

TbHuidou tbHuidou = new TbHuidou();

tbHuidou.setCf_no(“1”);

tbHuidou.setDzh_no(“1”);

tbHuidou.setLc_no(“1”);

tbHuidou.setProduct_code(“1”);

tbHuidou.setFunction_id(“1”);

tbHuidou.setProduct_type(“1”);

tbHuidous.add(tbHuidou);

TbHuidou tbHuidou2 = new TbHuidou();

tbHuidou2.setCf_no(“2”);

tbHuidou2.setDzh_no(“2”);

tbHuidou2.setLc_no(“2”);

tbHuidou2.setProduct_code(“2”);

tbHuidou2.setFunction_id(“2”);

tbHuidou2.setProduct_type(“2”);

tbHuidous.add(tbHuidou2);

TbHuidou tbHuidou3 = new TbHuidou();

tbHuidou3.setCf_no(“9”);

tbHuidou3.setDzh_no(“9”);

tbHuidou3.setLc_no(“9”);

tbHuidou3.setProduct_code(“9”);

tbHuidou3.setFunction_id(“9”);

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5436663.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-11
下一篇 2022-12-11

发表评论

登录后才能评论

评论列表(0条)

保存