I have the following expression:
scheduleIntervalContainers.stream()
.filter(sic -> ((ScheduleIntervalContainer) sic).getStartTime() != ((ScheduleIntervalContainer)sic).getEndTime())
.collect(Collectors.toList());
...where scheduleIntervalContainers
has element type ScheduleContainer
:
final List<ScheduleContainer> scheduleIntervalContainers
Is it possible to check the type before the filter?
Not exactly a stream, but Guava's FluentIterable
does this very cleanly:
FluentIterable.from(scheduleIntervalContainers)
.filter(ScheduleIntervalContainer.class)
.filter(sic -> sic.getStartTime() != sic.getEndTime())
.toList();