src/main/java/org/gbif/ala/spatial/LayerCrawler.java
/**
   * Util to partition a stream into fixed size windows.
   * See https://e.printstacktrace.blog/divide-a-list-to-lists-of-n-size-in-Java-8/
   */
Util to partition a stream into fixed size windows.
Util to partition a stream into fixed size windows .
private static <T> Collection<List<T>> partition(Stream<T> stream, int size) {
    final AtomicInteger counter = new AtomicInteger(0);
    return stream
        .collect(Collectors.groupingBy(it -> counter.getAndIncrement() / size))
        .values();
  }
private static < T > Collection < List < T > > partition ( Stream < T > stream , int size ) { final AtomicInteger counter = new AtomicInteger ( 0 ) ; return stream . collect ( Collectors . groupingBy ( it -> counter . getAndIncrement ( ) / size ) ) . values ( ) ; }
Util to partition a stream into fixed size windows.
Util to partition a stream into fixed size windows .