Javaの文法jdk8記録
1.所望の結果は、最初に取るために濾過しました
オプションの株式= vo.stream()フィルタ(V - >「100」.equals(page.getProductCode()))関数は、FindFirst()。;。
IF(stock.isPresent()){
StockWarQueryVo stock4 = stock.get()。
stockVo.setProductName(stock4.getProductName())。
}
所望の結果セットのうち2フィルタ
リストvehicleInfos = list.stream()フィルタ( - > 100 == a.getSysOrgId())を収集(Collectors.toList())。
3.削除IDS
。リストproductCodes = vo.stream()マップ(StockWarQueryVo :: getProductCode).collect(Collectors.toList());
マップにキーに4.list ID
地図<ロング、ユーザー>にマッピング= userList.stream()コレクト(Collectors.toMap(ユーザー::のgetId、Function.identity()));
属性のグループ化
地図<文字列、一覧> detailsMap01 = list.stream()
.collect(Collectors.groupingBy(ユーザー::のgetId));
6.ソート
(1)昇順
Collections.sort(その結果、Comparator.comparing(ProVendorCategoryTreeVo :: getClassifySort));
(2)降順
Collections.sort(その結果、Comparator.comparing(ProVendorCategoryTreeVo :: getClassifySortは))(.reversed)。
(3)第一下降し、その後上昇
Collections.sort(その結果、Comparator.comparing(ProVendorCategoryTreeVo :: getClassifySort))thenComparing(ProVendorCategoryTreeVo ::のgetId)(.reversed)。