Source:
public Set<ResolvedBroadcast> aggregateBroadcasts( Set<Broadcast> broadcasts, Optional<Platform> platformOptional, List<Id> downweighChannelIds, boolean includePastBroadcasts ) { Set<Broadcast> platformBroadcasts = platformOptional.isPresent() ? removeBroadcastsNotOnPlatform(broadcasts, platformOptional.get()) : broadcasts; Set<Broadcast> mergedContinuations = mergeBroadcastContinuations(platformBroadcasts); if (!includePastBroadcasts) { mergedContinuations = mergedContinuations.stream() .filter(broadcast -> broadcast.getTransmissionEndTime().isAfterNow()) .collect(Collectors.toSet()); } Multimap<DateTime, ResolvedBroadcast> broadcastMap = mergedContinuations.stream() .map(broadcast -> ResolvedBroadcast.create( broadcast, ResolvedChannel.builder(resolveChannel(broadcast.getChannelId())).build()) ) .filter(resolved -> isNotTimeshiftedOrHd(resolved.getResolvedChannel().getChannel())) .collect(MoreCollectors.toImmutableListMultiMap( resolvedBroadcast -> resolvedBroadcast.getBroadcast().getTransmissionTime(), resolvedBroadcast -> resolvedBroadcast )); ImmutableMultimap.Builder<DateTime, ResolvedBroadcast> aggregatedBroadcasts = ImmutableMultimap.builder(); for(DateTime dateTime : broadcastMap.keySet()) { Collection<ResolvedBroadcast> sameTimeBroadcasts = broadcastMap.get(dateTime); if (sameTimeBroadcasts.size() > 1) { aggregatedBroadcasts.putAll( dateTime, aggregateBroadcastsInternal(sameTimeBroadcasts, platformOptional) ); } else { aggregatedBroadcasts.put(dateTime, Iterables.getOnlyElement(sameTimeBroadcasts)); } } return sortByDownweighChannelIds( downweighChannelIds, sortBroadcastsByDateTime(aggregatedBroadcasts.build()) ); }

Target:
public Set<ResolvedBroadcast> aggregateBroadcasts( Set<Broadcast> broadcasts, Optional<Platform> platformOptional, List<Id> downweighChannelIds, boolean includePastBroadcasts ) { Set<Broadcast> platformBroadcasts = platformOptional.isPresent() ? removeBroadcastsNotOnPlatform(broadcasts, platformOptional.get()) : broadcasts; Stream<Broadcast> mergedContinuations = mergeBroadcastContinuations(platformBroadcasts).stream(); if (!includePastBroadcasts) { mergedContinuations = removePastBroadcasts(mergedContinuations); } Multimap<DateTime, ResolvedBroadcast> broadcastMap = mergedContinuations.map( broadcast -> ResolvedBroadcast.create( broadcast, ResolvedChannel.builder(resolveChannel(broadcast.getChannelId())).build()) ) .filter(resolved -> isNotTimeshiftedOrHd(resolved.getResolvedChannel().getChannel())) .collect(MoreCollectors.toImmutableListMultiMap( resolvedBroadcast -> resolvedBroadcast.getBroadcast().getTransmissionTime(), resolvedBroadcast -> resolvedBroadcast )); ImmutableMultimap.Builder<DateTime, ResolvedBroadcast> aggregatedBroadcasts = ImmutableMultimap.builder(); for(DateTime dateTime : broadcastMap.keySet()) { Collection<ResolvedBroadcast> sameTimeBroadcasts = broadcastMap.get(dateTime); if (sameTimeBroadcasts.size() > 1) { aggregatedBroadcasts.putAll( dateTime, aggregateBroadcastsInternal(sameTimeBroadcasts, platformOptional) ); } else { aggregatedBroadcasts.put(dateTime, Iterables.getOnlyElement(sameTimeBroadcasts)); } } return sortByDownweighChannelIds( downweighChannelIds, sortBroadcastsByDateTime(aggregatedBroadcasts.build()) ); }