package org.gitlab4j.api;

import java.util.Collections;
import java.util.Iterator;
import java.util.Spliterator;
import java.util.function.Consumer;

class PagerSpliterator<T> implements Spliterator<T> {

	private Pager<T> pager;

	private Iterator<T> elements;

	PagerSpliterator(Pager<T> pager) {
		this.pager = pager;
		if (pager.hasNext()) {
			elements = this.pager.next().iterator();
		} else {
			elements = Collections.emptyIterator();
		}
	}

	@Override
	public boolean tryAdvance(Consumer<? super T> action) {
		if (action == null) {
			throw new NullPointerException("Action is null");
		}
		if (elements.hasNext()) {
			action.accept(elements.next());
			return true;
		} else if (pager.hasNext()) {
			elements = pager.next().iterator();
			action.accept(elements.next());
			return true;
		}
		return false;
	}

	@Override
	public Spliterator<T> trySplit() {
		return null;
	}

	@Override
	public long estimateSize() {
		return pager.getTotalItems();
	}

	@Override
	public int characteristics() {
		return SIZED | NONNULL;
	}
}

@@ -745,16 +745,45 @@
 ator();%0A
+%09%09%09if(elements.hasNext()) %7B%0A%09
 %09%09%09actio
@@ -804,32 +804,33 @@
 nts.next());%0A%09%09%09
+%09
 return true;%0A%09%09%7D
@@ -826,16 +826,21 @@
 n true;%0A
+%09%09%09%7D%0A
 %09%09%7D%0A%09%09re

Update PagerSpliterator.java