RenameOperation { public static void renamePrefixes( OWLOntology ontology, IOHelper ioHelper, Map<String, String> mappings) { OWLOntologyManager manager = ontology.getOWLOntologyManager(); OWLEntityRenamer entityRenamer = new OWLEntityRenamer(manager, Sets.newHashSet(ontology)); Set<IRI> allIRIs = OntologyHelper.getIRIs(ontology); for (Map.Entry<String, String> mapping : mappings.entrySet()) { String oldBase = mapping.getKey(); String newBase = mapping.getValue(); Set<IRI> matchIRIs = allIRIs .stream() .filter(iri -> iri.toString().startsWith(oldBase)) .collect(Collectors.toSet()); if (matchIRIs.isEmpty()) { logger.warn(String.format("No entities with prefix '%s' to rename", oldBase)); continue; } for (IRI iri : matchIRIs) { IRI newIRI = ioHelper.createIRI(iri.toString().replace(oldBase, newBase)); manager.applyChanges(entityRenamer.changeIRI(iri, newIRI)); } } }  static void renameFull(
      OWLOntology ontology, IOHelper ioHelper, Map<String, String> mappings); static void renamePrefixes(
      OWLOntology ontology, IOHelper ioHelper, Map<String, String> mappings);  }
@Test public void testPartialRename() throws Exception { OWLOntology ont = loadOntology("/simple.owl"); Map<String, String> mappings = new HashMap<>(); mappings.put( "https: "http: RenameOperation.renamePrefixes(ont, new IOHelper(), mappings); assertIdentical("/rename_partial.owl", ont); }