org.protege.owlapi.util.ImportsClosureComparator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of protege-owlapi-extensions Show documentation
Show all versions of protege-owlapi-extensions Show documentation
Extensions to the OWL API (http://owlapi.sourceforge.net/) for Protege
package org.protege.owlapi.util;
import java.util.Comparator;
import org.semanticweb.owlapi.model.OWLOntology;
public class ImportsClosureComparator implements Comparator {
public int compare(OWLOntology o1, OWLOntology o2) {
boolean o1ImportsO2 = o1.getImportsClosure().contains(o2);
boolean o2ImportsO1 = o2.getImportsClosure().contains(o1);
if (o1ImportsO2 && !o2ImportsO1) {
return 1;
}
else if (o2ImportsO1 && !o1ImportsO2) {
return -1;
}
else {
return o1.compareTo(o2);
}
}
}