List<BetLimit> changeBetLimitList = list.stream().filter(item -> item.getSingleOrderMinStake() < oldData.getSingleOrderMinStake()).collect(Collectors.toList())
Map<Integer, BetLimit> oldBetLimitMap = oldBetLimitList.stream().collect(Collectors.toMap(BetLimit::getId, o -> o))
List提取属性放入List
java
List<Integer> betItemIdList = list.stream().map(Order::getBetItemId).distinct().collect(Collectors.toList());
String inIds = accountIdList.stream().map(i -> i.toString()).collect(Collectors.joining(","));
Map<BigDecimal, List<Item>> groupByPriceMap=
items.stream().collect(Collectors.groupingBy(Item::getPrice));
Map<Integer, Map<String, PercentDistribution>> percentDistributionLotteryMap = percentDistributionList.stream().collect (Collectors.groupingBy(PercentDistribution::getAccountId, Collectors.toMap (PercentDistribution::getLotteryCode, o -> o)));
8.BigDecimal求和app
int totalBetStake = list.stream().map(Order::getBetStake).reduce(BigDecimal.ZERO, BigDecimal::add) .intValue();
9.groupBy转换Map类型code
Map<Date, List<Order>> dateOrderMap = orderList.stream().collect(Collectors.groupingBy(Order::getReportDate, LinkedHashMap::new, Collectors.toList()));
10.List中对象多个属性求和,并返原对象对象
A a = list.stream() .reduce((x , y) -> new A( (x.getPrincipal() + y.getPrincipal()), (x.getFee() + y.getFee()) ) ).orElse( new A(0, 0) );ip
11.groupby 按某个属性分组,并收集为一个属性集合ci
Map<Integer, List<Integer>> collect = list.stream().collect(Collectors.groupingBy(record -> record .getInt("accountId"), Collectors.mapping(record -> record.getInt("permissionId"), Collectors.toList())