void handleChanges(@Nonnull List<? extends OWLOntologyChange> changes) { if (ontologies == null) { return; } Set<OWLEntity> processed = new HashSet<OWLEntity>(); for (OWLOntologyChange chg : changes) { if (ontologies.contains(chg.getOntology())) { if (chg.isAddAxiom()) { AddAxiom addAx = (AddAxiom) chg; for (OWLEntity ent : addAx.getSignature()) { assert ent != null; if (!processed.contains(ent)) { processed.add(ent); add(ent); } } } else if (chg.isRemoveAxiom()) { RemoveAxiom remAx = (RemoveAxiom) chg; for (OWLEntity ent : remAx.getSignature()) { assert ent != null; if (!processed.contains(ent)) { processed.add(ent); boolean stillRef = false; for (OWLOntology ont : ontologies) { if (ont.containsEntityInSignature(ent)) { stillRef = true; break; } } if (!stillRef) { remove(ent); } } } } } } }