Here you can find the source of getFailedMiddlePartNumbers(PartListing partListing)
static Set<Integer> getFailedMiddlePartNumbers(PartListing partListing)
//package com.java2s; //License from project: Apache License import com.amazonaws.services.s3.model.PartListing; import com.amazonaws.services.s3.model.PartSummary; import java.util.Set; import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; import java.util.stream.IntStream; public class Main { static Set<Integer> getFailedMiddlePartNumbers(PartListing partListing) { AtomicInteger lastPartNumber = new AtomicInteger(0); Set<Integer> uploadedParts = partListing.getParts().stream() .map(PartSummary::getPartNumber) .peek(n -> {// w ww. ja v a 2s . c om if (lastPartNumber.get() < n) { lastPartNumber.set(n); } }) .collect(Collectors.toSet()); return IntStream.range(1, lastPartNumber.get()) .filter(n -> !uploadedParts.contains(n)) .boxed() .collect(Collectors.toSet()); } }