<commit_before>package uk.ac.ebi.quickgo.common.validator;

import java.util.Arrays;
import java.util.List;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * Gene product IDs that don't match the regular expressions for recognised/supported gene product types should be
 * rejected with an error; those that do match should be treated as valid (plausible), even if they don't actually
 * identify a gene product in any of the supported databases.
 * The supported databases should be: UniProtKB, RNAcentral, IntAct, and any of the databases that are available in
 * the ID mapping function.
 *
 * @author <NAME>
 * Date: 14/06/2016
 * Time: 13:32
 * Created with IntelliJ IDEA.
 */

public class GeneProductIDValidator implements ConstraintValidator<GeneProductIDList,String>{

    @Autowired
    EntityValidation xRefFormats;
    Predicate<String> idValidator;

    @Override public void initialize(GeneProductIDList constraintAnnotation) {
        idValidator = xRefFormats::isValidId;
    }

    @Override public boolean isValid(String s, ConstraintValidatorContext constraintValidatorContext) {
        if(s==null)return true;
        List invalidGeneProdIDs = Arrays.stream(s.split(",")).filter(idValidator.negate()).collect
                (Collectors.toList());
        return invalidGeneProdIDs.size() == 0;
    }
}<commit_msg>Reduce member variable visibility.<commit_after>package uk.ac.ebi.quickgo.common.validator;

import java.util.Arrays;
import java.util.List;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * Gene product IDs that don't match the regular expressions for recognised/supported gene product types should be
 * rejected with an error; those that do match should be treated as valid (plausible), even if they don't actually
 * identify a gene product in any of the supported databases.
 * The supported databases should be: UniProtKB, RNAcentral, IntAct, and any of the databases that are available in
 * the ID mapping function.
 *
 * @author <NAME>
 * Date: 14/06/2016
 * Time: 13:32
 * Created with IntelliJ IDEA.
 */

public class GeneProductIDValidator implements ConstraintValidator<GeneProductIDList,String>{

    @Autowired
    EntityValidation xRefFormats;
    private Predicate<String> idValidator;

    @Override public void initialize(GeneProductIDList constraintAnnotation) {
        idValidator = xRefFormats::isValidId;
    }

    @Override public boolean isValid(String s, ConstraintValidatorContext constraintValidatorContext) {
        if(s==null)return true;
        List invalidGeneProdIDs = Arrays.stream(s.split(",")).filter(idValidator.negate()).collect
                (Collectors.toList());
        return invalidGeneProdIDs.size() == 0;
    }
}
{'fraction_non_alphanumeric': 0.08536189548847777, 'fraction_numerical': 0.008438818565400843, 'mean_word_length': 4.523297491039426, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1119974', 'n_tokens_mistral': 854, 'n_tokens_neox': 806, 'n_words': 254}