- Spring 5.0 By Example
- Claudio Eduardo de Oliveira
- 70字
- 2025-02-25 18:46:33
Keeping the news safely
Also, we need to check if the news is fully revised by all mandatory reviewers. It is quite simple, we are using Java 8, and it provides the amazing Stream interface, which makes the collections interactions easier than before. Let's do this:
public Boolean revised() {
return this.mandatoryReviewers.stream().allMatch(reviewer -> this.reviewers.stream()
.anyMatch(review -> reviewer.id.equals(review.userId) && "approved".equals(review.status)));
}
Thanks, Java 8, we appreciate it.