Consider this example: I have a list of RangeSet that contains, for instance, timestamps. I want to get the total duration of ranges using java8 streams instead of the imperativ
It looks like you're just looking for Stream.flatMap, e.g.
long totalTime = list.stream() .flatMap(rangeset -> rangeset.asRanges().stream()) .map(range -> range.upperEndpoint() - range.lowerEndpoint()) .reduce(0, (total, time) -> total + time);