All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.nlp2rdf.validator.NIFBeanContextValidator Maven / Gradle / Ivy

There is a newer version: 0.4.1
Show newest version
package org.nlp2rdf.validator;


import org.nlp2rdf.bean.NIFBean;
import org.nlp2rdf.bean.NIFType;
import org.nlp2rdf.exception.NIFException;

import java.util.List;

public class NIFBeanContextValidator implements NIFMessagesException {

    public static void checkIfContextExists(List beans) {
        if (!beans.stream().filter(bean -> NIFType.CONTEXT.equals(bean.getNifType())).findFirst().isPresent()) {
            throw new NIFException(NIF_STRUCTURE_CONTEXT_NOT_FOUND);
        }
    }

    public static void checkIfHasDuplicatedContext(List beans) {
        if (beans.stream().filter(bean -> NIFType.CONTEXT.equals(bean.getNifType())).count() > 1) {
            throw new NIFException(NIF_STRUCTURE_DUPLICATED_CONTEXT);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy