0
:Java8 람다 기능 - 추가 새 매개 변수 나는 다음 코드 한
categoryList = Prices.stream()
.filter(price -> price.getPrice() != null)
.map(this::createCategory)
.filter(Objects::nonNull)
.collect(Collectors.toList());
과 같은 방법이 보인다 : 나는 방법 createCategory에 새 매개 변수를 추가 할
private Category createCategory(PriceCategory price) {
Category category = new Category();
category.setId(price.getId());
return category;
}
-createCategory(PriceCategory price, response)
좋아하지만 나는이 새로운 매개 변수를 lamda 함수에 설정하는 것에 대해 모른다. 누구든지이 도움을 청할 수 있습니까
메서드 참조를 사용하고 있습니다. 그냥 람다 식으로 바꾸면 문제가 사라집니다 (힌트 : 람다 식은 앞의'filter' 단계에서 사용하고있는 식입니다). – Holger
가능하지만'response' 값이 어디에서 오는지 먼저 정의해야합니다. –