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


import uk.ac.ebi.quickgo.index.annotation.Annotation;

import java.util.function.Predicate;
import org.springframework.batch.item.ItemProcessor;

/**
 * @author Tony Wardell
 * Date: 06/09/2016
 * Time: 16:30
 * Created with IntelliJ IDEA.
 *
 * A version of ItemProcessor for adding details from an {@link uk.ac.ebi.quickgo.index.annotation.Annotation}
 * to a matrix of permutations where GOTerm A and GOTerm B both annotate the same Gene Product.
 *
 * Version of GPAFileToSummary from Beta
 */
public class AnnotationCoStatsProcessor implements ItemProcessor<Annotation, Annotation> {

    private final CoStatsPermutations coStatsPermutations;
    private final Predicate<Annotation> toBeProcessed;

    public AnnotationCoStatsProcessor(CoStatsPermutations coStatsPermutations,
            Predicate<Annotation> toBeProcessed) {
        this.coStatsPermutations = coStatsPermutations;
        this.toBeProcessed = toBeProcessed;
    }

    @Override
    public Annotation process(Annotation annotation) throws Exception {

        if(toBeProcessed.test(annotation)){
            coStatsPermutations.addRowToMatrix(annotation);
        }

        return annotation;
    }
}

@@ -102,16 +102,61 @@
 ation;%0A%0A
+import com.google.common.base.Preconditions;%0A
 import j
@@ -875,29 +875,16 @@
 tations,
-%0A            
 Predicat
@@ -889,32 +889,149 @@
 ate%3CAnnotation%3E 
+toBeProcessed) %7B%0A        Preconditions.checkArgument(coStatsPermutations!=null);%0A        Preconditions.checkArgument(
 toBeProcessed) %7B
@@ -1019,35 +1019,40 @@
 nt(toBeProcessed
-) %7B
+!=null);
 %0A        this.co

Add some preconditions to check state of constructor arguments.