package uk.ac.ebi.quickgo.annotation.validation;

import java.util.stream.Stream;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * Validate the reference values used to filter annotations.
 * There is a limited list of databases that can be used as the database portion of the identifier, defined within
 * this class.
 *
 * @author Tony Wardell
 * Date: 10/11/2016
 * Time: 13:22
 * Created with IntelliJ IDEA.
 */
class ReferenceValuesValidation implements ConstraintValidator<ReferenceValidator, String[]> {

    @Autowired
    private ReferenceDBXRefEntityValidation validator;

    @Override public void initialize(ReferenceValidator constraintAnnotation) {}

    @Override public boolean isValid(String[] values, ConstraintValidatorContext context) {
        return values == null || Stream.of(values).allMatch(validator::isValid);
    }
}

@@ -43,16 +43,135 @@
 ation;%0A%0A
+import com.google.common.base.Preconditions;%0Aimport java.util.Arrays;%0Aimport java.util.List;%0Aimport java.util.Objects;%0A
 import j
@@ -194,16 +194,16 @@
 Stream;%0A
-
 import j
@@ -355,16 +355,88 @@
 wired;%0A%0A
+import static uk.ac.ebi.quickgo.annotation.validation.IdValidation.db;%0A%0A
 /**%0A * V
@@ -838,25 +838,8 @@
     
-private Reference
 DBXR
@@ -867,16 +867,111 @@
 lidator;
+%0A    private List%3CString%3E referenceDatabases = Arrays.asList(%22pmid%22,%22doi%22,%22go_ref%22,%22reactome%22);
 %0A%0A    @O
@@ -1202,26 +1202,448 @@
 tch(
-validator::
+this::isValid);%0A    %7D%0A%0A    private boolean isValid(String value)%7B%0A        Preconditions.checkArgument(Objects.nonNull(value), %22The value for id cannot be null%22);%0A%0A        if (value.trim().isEmpty()) %7B%0A            return false;%0A        %7D%0A%0A        if (!value.contains(%22:%22)) %7B%0A            return true;%0A        %7D%0A%0A        if (!referenceDatabases.contains(db(value))) %7B%0A            return false;%0A        %7D%0A%0A        return validator.
 isValid
+(value
 );%0A 

Add logic for reference validation directly to this class.