Collectors.groupingBy(e -> e.getResrcSuplCode() + "_" + e.getCustNo(), (Collector)Collectors.toList());
时间: 2024-05-14 16:14:06 浏览: 95
This code snippet groups a collection of objects by a combination of two properties, namely "resrcSuplCode" and "custNo". It uses the "groupingBy" method of the "Collectors" class to achieve this.
The syntax of the "groupingBy" method is as follows:
```
groupingBy(Function<? super T, ? extends K> classifier, Collector<? super T, A, D> downstream)
```
where:
- "classifier" is a function that extracts the grouping key from each element of the collection
- "downstream" is a collector that accumulates the elements of each group into a result container
In the given code snippet, the "classifier" function is defined using a lambda expression that concatenates the values of the "resrcSuplCode" and "custNo" properties with an underscore separator. This ensures that each group key is unique and consists of both properties.
The "downstream" collector is defined using the "toList" method of the "Collectors" class, which collects the elements of each group into a new list.
Overall, this code snippet performs a simple grouping operation on a collection of objects based on a combination of two properties.
阅读全文