qum*_*uma 8 lambda optional java-8 java-stream
我有以下lambda表达式,如果bonusScheduleDurationContainers不为空则工作正常.如果它是空的,我会得到一个NoSuchElementException.我如何在lambda表达式中检查这个?
final List<ScheduleDurationContainer> bonusScheduleDurationContainers
= scheduleDurationContainersOfWeek.stream()
.filter(s -> s.getContainerType() == ScheduleIntervalContainerTypeEnum.BONUS)
.collect(Collectors.toList());
final ScheduleDurationContainer bonusScheduleDurationContainer
= bonusScheduleDurationContainers.stream()
.filter(s -> s.getDayOfWeekStartingWithZero() == dayOfWeekTmp)
.findFirst()
.get();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
15769 次 |
| 最近记录: |