class OntologyModels {

    public static Optional<IRI> findFirstVersionIRI(Model model, IRI ontologyIRI, ValueFactory vf) {
        Optional<Value> optionalValue = Models.findFirstObject(model, ontologyIRI, vf.createIRI(OWL.VERSIONIRI.stringValue()));
        if (optionalValue.isPresent() && optionalValue.get() instanceof IRI) {
            return Optional.of((IRI) optionalValue.get());
        }
        return Optional.empty();
    }

}