嗨! 尝试使用此流,但我遇到了 NoSuchElementException
var scores = findAllByBarcode
.stream()
.iterator()
.next()
.getMpProductFeedbacks()
.stream()
.filter(mpProductFeedback -> mpProductFeedback.getId()==mpProductFeedbackId)
.iterator()
.next()
.getMpPersonScores()
.stream()
.map(mpPersonScore -> {
var score = new ScoreType();
score.setUserScore(mpPersonScore.getMpPersonScore());
score.setUser(mpPersonScore.getMpPersonLogin());
score.setUserComment(mpPersonScore.getMpPersonComment());
return score;
})
.toList();
部分后出现异常
filter(mpProductFeedback -> mpProductFeedback.getId()==mpProductFeedbackId)
.iterator()
.next()
尝试使用 orElse,但它仅适用于 .equals 我已经在两个 long 之间有 == 了。
嗯,听起来没有满足条件的元素。考虑使用
findFirst()
而不是 .iterator().next()
来正确处理 Optional
。