private Object readSource()

in commons-rdf-jsonld-java/src/main/java/org/apache/commons/rdf/jsonldjava/experimental/JsonLdParser.java [151:168]


    private Object readSource() throws IOException {
        // Due to checked IOException we can't easily
        // do this with .map and .orElseGet()

        if (getSourceInputStream().isPresent()) {
            return JsonUtils.fromInputStream(getSourceInputStream().get());
        }
        if (getSourceIri().isPresent()) {
            // TODO: propagate @base from content
            return JsonUtils.fromURL(asURL(getSourceIri().get()), JsonUtils.getDefaultHttpClient());
        }
        if (getSourceFile().isPresent()) {
            try (InputStream inputStream = Files.newInputStream(getSourceFile().get())) {
                return JsonUtils.fromInputStream(inputStream);
            }
        }
        throw new IllegalStateException("No known source found");
    }