class OntologyCacheImpl implements OntologyCache {

    @Override
    public void clearCacheImports(Resource ontologyIRI) {
        Optional<Cache<String, Ontology>> optCache = getOntologyCache();
        optCache.ifPresent(cache -> {
            Set<String> cachesToRemove = new HashSet<>();
            for (Cache.Entry<String, Ontology> entry : cache) {
                Set<? extends Resource> importedIRIs = entry.getValue().getImportedOntologyIRIs();
                if (importedIRIs.contains(ontologyIRI)) {
                    cachesToRemove.add(entry.getKey());
                }
            }
            cache.removeAll(cachesToRemove);
        });
    }

}