Java嵌套遍历两个List来实现数据组合
============List<CtServiceAddrDTO>
[CtServiceAddrDTO [accessip=192.168.12.174, bakassessip=0.0.0.0, channelID=169600001, type=1, groupID=168382519], CtServiceAddrDTO [accessip=192.168.12.174, bakassessip=0.0.0.0, channelID=169600003, type=775, groupID=168382521],CtServiceAddrDTO [accessip=192.168.12.174, bakassessip=0.0.0.0, channelID=169600005, type=776, groupID=168382523], CtServiceAddrDTO [accessip=192.168.12.174, bakassessip=0.0.0.0, channelID=169600007, type=777, groupID=168382525], CtServiceAddrDTO [accessip=192.168.12.174, bakassessip=0.0.0.0, channelID=169600009, type=258, groupID=168382527],
CtServiceAddrDTO [accessip=192.168.12.174, bakassessip=0.0.0.0, channelID=169600011, type=259, groupID=168382529], CtServiceAddrDTO [accessip=192.168.12.174, bakassessip=0.0.0.0, channelID=169600013, type=516, groupID=168382531]]
============List<DtServiceAddrDTO>
[DtServiceAddrDTO [transportip=192.168.12.176, channelID=169600002, type=1, groupID=168382520], DtServiceAddrDTO [transportip=192.168.12.176, channelID=169600004, type=775, groupID=168382522], DtServiceAddrDTO [transportip=192.168.12.176, channelID=169600006, type=776, groupID=168382524], DtServiceAddrDTO [transportip=192.168.12.176, channelID=169600008, type=777, groupID=168382526], DtServiceAddrDTO [transportip=192.168.12.176, channelID=169600010, type=258, groupID=168382528], DtServiceAddrDTO [transportip=192.168.12.176, channelID=169600014, type=516, groupID=168382532]]
需要嵌套遍历上面两个List来生成如下的内容。生成的原理为:根据相同type组合两个List的channelID与groupID,如果遇到A List中的type在B中不存在的话,就添加A中的type对应的数据,如果遇到B list中的type在A中不存在,就添加B中的type对应的数据。
形如:
type1|第1个List中的channelID|第1个List中的groupID|第2个List中的channelID|第2个List中的groupID|
type2|第1个List中的channelID|第1个List中的groupID|
type3|第1个List中的channelID|第1个List中的groupID|第2个List中的channelID|第2个List中的groupID|
type4|第1个List中的channelID|第1个List中的groupID|第2个List中的channelID|第2个List中的groupID|
具体示例如下:
channel_info:
1|169600001|168382519|169600002|168382520|
775|169600003|168382521|169600004|168382522|
776|169600005|168382523|169600006|168382524|
777|169600007|168382525|169600008|168382526|
258|169600009|168382527|169600010|168382528|
259|169600011|168382529|
516|169600013|168382531|169600014|168382532