Java 8 stream - cast list items to type of subclass
<p>I have a list of <code>ScheduleContainer</code> objects and in the stream each element should be casted to type <code>ScheduleIntervalContainer</code>. Is there a way of doing this? </p>

<pre><code>final List&lt;ScheduleContainer&gt; scheduleIntervalContainersReducedOfSameTimes

final List&lt;List&lt;ScheduleContainer&gt;&gt; scheduleIntervalContainerOfCurrentDay = new ArrayList&lt;&gt;(
        scheduleIntervalContainersReducedOfSameTimes.stream()
            .sorted(Comparator.comparing(ScheduleIntervalContainer::getStartDate).reversed())
            .filter(s -&gt; s.getStartDate().withTimeAtStartOfDay().isEqual(today.withTimeAtStartOfDay())).collect(Collectors
                .groupingBy(ScheduleIntervalContainer::getStartDate, LinkedHashMap::new, Collectors.&lt;ScheduleContainer&gt; toList()))
            .values());
</code></pre>