반응형
class Product {
private String code;
private String name;
private String category;
private long price;
}
List<Product> products = Arrays.asList();
//코드,이름 카테고리 3개의 필드가 중복되는 상품 제거.
Collection<Product> removes = products
.stream()
.collecti(toMap(
p -> Arrays.asList(p.getCode(),p.getName(),p.getCategory()),
Function.identity(),(p1,p2) -> p1))
.values();
반응형
'SpringBoot' 카테고리의 다른 글
Flux and Mono (0) | 2020.07.14 |
---|---|
how to generate random number or Alphabetic in java (0) | 2020.04.30 |
Java Object Stream group by multiple field and map in map to list (0) | 2020.01.05 |
JPA - Join (0) | 2019.12.08 |
spring controller async request process with executor (0) | 2019.10.05 |