我有以下信息流:
final List<List<ScheduleContainer>> scheduleIntervalContainerOfCurrentDay = new ArrayList<>(
unconfirmedScheduleIntervalContainersOfWeeks.stream()
.sorted(Comparator.comparing(ScheduleIntervalContainer::getStartDate).reversed())
.filter(s -> s.getStartDate().withTimeAtStartOfDay().isEqual(today.withTimeAtStartOfDay()))
.collect(Collectors.groupingBy(ScheduleIntervalContainer::getStartDate, LinkedHashMap::new, Collectors.toList())).values());
最后我将从类型List
的{{1}}转换为类型List<ScheduleIntervalContainer>
的{{1}}(ScheduleIntervalContainer是ScheduleContainer的子类型)。有没有办法做到这一点?
答案 0 :(得分:4)
您可以通过指定要用于toList
的类型参数,将项目收集到更常规类型的列表中:
Collectors.<ScheduleContainer>toList()