package uk.ac.ebi.quickgo.rest.search.query;

import java.util.Arrays;
import java.util.List;

/**
 * Holds the data required to specify a filter value
 *
 * @author Tony Wardell
 * Date: 03/05/2016
 * Time: 10:25
 * Created with IntelliJ IDEA.
 */
public class PrototypeFilter {

    private static final String COMMA = ",";
    private String filterField;
    private List<String> args;
    private Validator<String> validator;

    public String getFilterField() {
        return filterField;
    }

    public List<String> getArgs() {
        return args;
    }

    public static final PrototypeFilter create(String filterField, String argIncludingDelimiters, Validator<String>
            validator ){
        PrototypeFilter prototypeFilter = new PrototypeFilter();
        prototypeFilter.filterField = filterField;
        prototypeFilter.args = Arrays.asList(argIncludingDelimiters.split(COMMA));
        prototypeFilter.validator = validator;
        return prototypeFilter;
    }

    /**
     *
     * Test each argument in the list to see if its valid
     */
    public void validate(){
        args.stream().forEach(a -> validator.validate(a));
    }
}

@@ -86,16 +86,48 @@
 il.List;
+%0Aimport java.util.stream.Stream;
 %0A%0A/**%0A *
@@ -532,71 +532,8 @@
  %7D%0A%0A
-    public List%3CString%3E getArgs() %7B%0A        return args;%0A    %7D%0A
 %0A   
@@ -1128,11 +1128,92 @@
 );%0A    %7D
+%0A%0A    public Stream%3CString%3E provideStream()%7B%0A        return args.stream();%0A%0A    %7D
 %0A%7D%0A

Stop direct access to the list of args, allow them to be streamed instead.