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

import uk.ac.ebi.quickgo.annotation.validation.model.ValidationEntities;
import uk.ac.ebi.quickgo.annotation.validation.model.ValidationEntity;

import java.util.*;
import java.util.Objects;

/**
 * Use the database cross reference information contained in this class to verify a list of potential database cross
 * reference identifiers.
 *
 * @author Tony Wardell
 * Date: 08/11/2016
 * Time: 14:41
 * Created with IntelliJ IDEA.
 */

public class ValidationEntityChecker {

    private final ValidationEntities<ValidationEntity> validationEntities;

    public ValidationEntityChecker(ValidationEntities<ValidationEntity> validationEntities) {
        this.validationEntities = validationEntities;
    }

    /**
     * If the value passed to this method can be successfully validated isValid will return true.
     * @param value a potential database cross reference identifier.
     * @return validation result.
     */

    public boolean isValid(String value) {
        return Objects.nonNull(value) && (!value.contains(":") || isValidAgainstEntity(value));
    }

    private boolean isValidAgainstEntity(String value) {
        final List<ValidationEntity> entities = validationEntities.get(DbCrossReferenceId.db(value));
        return entities != null && entities.stream().anyMatch(e -> e.test(DbCrossReferenceId.id(value)));
    }
}

@@ -564,34 +564,16 @@
 Entities
-%3CValidationEntity%3E
  validat
@@ -639,34 +639,16 @@
 Entities
-%3CValidationEntity%3E
  validat

Remove generics from ValidationEntities.