
package uk.ac.ebi.atlas.profiles.baseline;

import com.google.common.base.Joiner;
import com.google.common.collect.Iterables;
import uk.ac.ebi.atlas.model.experiment.baseline.BaselineExpression;
import uk.ac.ebi.atlas.model.experiment.baseline.FactorGroup;
import uk.ac.ebi.atlas.profiles.ExpressionsRowRawDeserializer;

import java.util.Iterator;
import java.util.List;
import java.util.Queue;

public class ExpressionsRowRawDeserializerBaseline extends ExpressionsRowRawDeserializer<BaselineExpression> {

    final int expectedNumberOfValues;
    Iterator<FactorGroup> factorGroups;

    public ExpressionsRowRawDeserializerBaseline(List<FactorGroup> orderedFactorGroups) {
        expectedNumberOfValues = orderedFactorGroups.size();
        factorGroups = Iterables.cycle(orderedFactorGroups).iterator();
    }

    @Override
    public ExpressionsRowRawDeserializer<BaselineExpression> reload(BaselineExpression... values) {
        if (values.length != expectedNumberOfValues) {
            throw new IllegalArgumentException(String.format("Expected %s values but got [%s]", expectedNumberOfValues, Joiner.on(",").join(values)));
        }
        return super.reload(values);
    }

    @Override
    public BaselineExpression nextExpression(Queue<BaselineExpression> rawValuesRow) {
        return rawValuesRow.poll();
    }

}

@@ -1,9 +1,8 @@
-%0A
 package 
@@ -79,52 +79,8 @@
 er;%0A
-import com.google.common.collect.Iterables;%0A
 impo
@@ -274,35 +274,8 @@
 r;%0A%0A
-import java.util.Iterator;%0A
 impo
@@ -438,13 +438,16 @@
     
-final
+private 
  int
@@ -474,48 +474,8 @@
 ues;
-%0A    Iterator%3CFactorGroup%3E factorGroups;
 %0A%0A  
@@ -558,24 +558,24 @@
 orGroups) %7B%0A
+
         expe
@@ -627,80 +627,8 @@
 ();%0A
-        factorGroups = Iterables.cycle(orderedFactorGroups).iterator();%0A
     

Remove field which was never accessed