我需要对ABC列表进行分组,同时我也想拆分值。
输入:
List<ABC> list = new ArrayList<>();
ABC A1 = new ABC();
A1.setName("OO");
A1.setVal("OO111,OO222,OO333"); // split this while grouping
list.add(A1);
ABC A2 = new ABC();
A2.setName("OO");
A2.setVal("OO1");
list.add(A2);
ABC A3 = new ABC();
A3.setName("YY");
A3.setVal("1333,11444");
list.add(A3);
输出:
Map<String, List<String>> postsPerType;
//Group by Name: ex: OO & YY. Split the Value by "," and add it to list
Key: 00 Values: List: "OO111","OO222","OO333","OO1"
Key: YY Values: List: "1333","11444"
请提供建议,谢谢。