package uk.ac.ebi.quickgo.client.service.loader.presets.evidence;

import uk.ac.ebi.quickgo.client.service.loader.presets.ff.RawNamedPresetColumnsBuilder;

import java.util.Comparator;
import java.util.stream.Stream;

/**
 * A specialisation of {@link RawEvidenceNamedPresetColumnsBuilder} used to create
 * {@link RawEvidenceNamedPresetColumnsImpl}
 * instances, which capture information about the column indices relating to a {@link RawEvidenceNamedPreset}.
 *
 * Created 05/03/18
 * @author Tony Wardell
 */
class RawEvidenceNamedPresetColumnsBuilder extends RawNamedPresetColumnsBuilder {
    private int goEvidencePosition;

    public RawEvidenceNamedPresetColumnsBuilder(int namePosition) {
        super(namePosition);
        this.goEvidencePosition = UNINITIALIZED_POSITION;
    }

    public RawEvidenceNamedPresetColumnsImpl build() {
        return new RawEvidenceNamedPresetColumnsImpl(this);
    }

    public RawEvidenceNamedPresetColumnsBuilder withGoEvidence(int _goEvidencePosition) {
        checkColumnPosition(_goEvidencePosition);
        this.goEvidencePosition = _goEvidencePosition;
        return this;
    }

    static RawEvidenceNamedPresetColumnsBuilder createWithNamePosition(int namePosition) {
        return new RawEvidenceNamedPresetColumnsBuilder(namePosition);
    }

    protected static class RawEvidenceNamedPresetColumnsImpl extends RawNamedPresetColumnsImpl {
        private int goEvidencePosition;

        protected RawEvidenceNamedPresetColumnsImpl(RawEvidenceNamedPresetColumnsBuilder builder) {
            super(builder);
            this.goEvidencePosition = builder.goEvidencePosition;
        }

        public int getGoEvidencePosition() {
            return goEvidencePosition;
        }

        @Override public int getMaxRequiredColumnCount() {
            if (maxRequiredColumnPosition == MAX_REQUIRED_COLUMN_POSITION_NOT_INITIALIZED) {
                maxRequiredColumnPosition =
                        Stream.of(
                                getDescriptionPosition(),
                                getIdPosition(),
                                getNamePosition(),
                                getRelevancyPosition(),
                                getAssociationPosition(),
                                getGoEvidencePosition()
                        ).max(Comparator.naturalOrder())
                                .map(columnPosition -> columnPosition + 1)
                                .orElse(DEFAULT_COLUMN_POSITION_NOT_INITIALIZED);
            }
            return maxRequiredColumnPosition;
        }
    }

}

@@ -625,29 +625,30 @@
 tion;%0A%0A    p
-ublic
+rivate
  RawEvidence
@@ -779,32 +779,46 @@
 OSITION;%0A    %7D%0A%0A
+    @Override%0A
     public RawEv
@@ -990,17 +990,16 @@
 nce(int 
-_
 goEviden
@@ -1040,17 +1040,16 @@
 osition(
-_
 goEviden
@@ -1095,17 +1095,16 @@
 ition = 
-_
 goEviden
@@ -1139,24 +1139,382 @@
 his;%0A    %7D%0A%0A
+    @Override%0A    public RawEvidenceNamedPresetColumnsBuilder withIdPosition(int idPosition) %7B%0A        super.withIdPosition(idPosition);%0A        return this;%0A    %7D%0A%0A    @Override%0A    public RawEvidenceNamedPresetColumnsBuilder withRelevancyPosition(int relevancyPosition) %7B%0A        super.withRelevancyPosition(relevancyPosition);%0A        return this;%0A    %7D%0A%0A
     static R
@@ -1808,24 +1808,24 @@
 ition;%0A%0A
+
         
 protecte
@@ -1816,26 +1816,16 @@
         
-protected 
 RawEvide

Add withIdPosition() & withRelevancyPosition() methods so RawEvidenceNamedPresetColumnsBuilder is returned, not it's superclass. Code tidy up.