ArrayList<ProductsReq> reqs = new ArrayList<>();
...
ProductsReq obj = reqs.stream()
.filter(productsReq -> "A".equals(productsReq.getProductName()))
.findFirst().get();
List<ProductsReq> list = reqs.stream()
.filter(productsReq -> "Test123".equals(productsReq.getMgmId()))
.collect(Collectors.toList());
Map<Integer, String> map = reqs.stream()
.filter(productsReq -> "Test123".equals(productsReq.getMgmId()))
.collect(Collectors.toMap(productsReq -> productsReq.getProduct_id(), productsReq -> productsReq.getProduct_name()));
String s = reqs.stream()
.map(productsReq -> productsReq.getProduct_name())
.findFirst().get();
String s = reqs.stream()
.map(productsReq -> productsReq.getProduct_name().toUpperCase())
.findFirst().get();
取得 產品ID 為 Key,產品底下所有卡片 為 Value 的 Map
Map<Integer, List<CardsView>> collect = reqs.stream()
.collect(Collectors.toMap(productsReq -> productsReq.getProduct_id(), productsReq -> productsReq.getCards()));
ProductsReq obj = reqs.stream()
.sorted(Comparator.comparing(ProductsReq::getCreateDate).reversed())
.findFirst().get();