package uk.ac.ebi.quickgo.index.annotation.coterms;

import java.util.Iterator;
import org.springframework.batch.item.ItemReader;

/**
 * @author Tony Wardell
 * Date: 07/09/2016
 * Time: 15:38
 * Created with IntelliJ IDEA.
 */
class Co_occurringTermItemReader implements ItemReader<String> {

    private final AnnotationCo_occurringTermsAggregator annotationCoOccurringTermsAggregator;
    private Iterator<String> termsIt;

    public Co_occurringTermItemReader(AnnotationCo_occurringTermsAggregator annotationCoOccurringTermsAggregator) {
        this.annotationCoOccurringTermsAggregator = annotationCoOccurringTermsAggregator;

    }

    @Override public String read() throws Exception {
        if (termsIt == null) {
            termsIt = annotationCoOccurringTermsAggregator.getTermToTermOverlapMatrix().keySet().iterator();
        }

        if (termsIt.hasNext()) {
            return termsIt.next();
        }

        return null;
    }
}

@@ -128,16 +128,227 @@
 r;%0A%0A/**%0A
+ * Provide a list of all GO Terms for which co-occurrence has been determined ( which is all of them that have been%0A * processed, since at worst a GO Term will have a statistic for co-occurring with itself).%0A *%0A
  * @auth
@@ -560,34 +560,8 @@
 or a
-nnotationCoOccurringTermsA
 ggre
@@ -740,34 +740,8 @@
 is.a
-nnotationCoOccurringTermsA
 ggre
@@ -847,16 +847,103 @@
 eption %7B
+%0A%0A        //Delay providing full list until aggregator has fully processed all records.
 %0A       
@@ -993,34 +993,8 @@
  = a
-nnotationCoOccurringTermsA
 ggre

Add some javadoc, notes and use a nicer name for AnnotationCo_occurringTermsAggregator.