纯手记
package com.company.demo0.demo0;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
public class Ttest {
public static void main(String[] args) {
List<XXX> makeXXXList = makeXXXList();
// 转map
Map<xxx,yyy> map = lll.stream().collect(Collectors.toMap(xxx::getxxx, xxx::getyyy));
// 按type分组
Map<Integer, List<XXX>> collect = makeXXXList.stream().collect(Collectors.groupingBy(XXX::getType));
System.out.println(collect);
//{0=[XXX{name='n0', type=0, price=0}, XXX{name='n5', type=0, price=5}], 1=[XXX{name='n1', type=1, price=1}, XXX{name='n4', type=1, price=4}], 2=[XXX{name='n2', type=2, price=2}, XXX{name='n