protected void checkSource()

in commons-rdf-simple/src/main/java/org/apache/commons/rdf/simple/experimental/AbstractRDFParser.java [214:230]


    protected void checkSource() throws IOException {
        if (!getSourceFile().isPresent() && !getSourceInputStream().isPresent() && !getSourceIri().isPresent()) {
            throw new IllegalStateException("No source has been set");
        }
        if (getSourceIri().isPresent() && getSourceInputStream().isPresent()) {
            throw new IllegalStateException("Both sourceIri and sourceInputStream have been set");
        }
        if (getSourceIri().isPresent() && getSourceFile().isPresent()) {
            throw new IllegalStateException("Both sourceIri and sourceFile have been set");
        }
        if (getSourceInputStream().isPresent() && getSourceFile().isPresent()) {
            throw new IllegalStateException("Both sourceInputStream and sourceFile have been set");
        }
        if (getSourceFile().isPresent() && !getSourceFile().filter(Files::isReadable).isPresent()) {
            throw new IOException("Can't read file: " + sourceFile);
        }
    }