if(cls instanceof OWLNamedClass){
// see if there are already necessary and sufficient restrictions
OWLAnonymousClass [] eq = getEquivalentRestrictionClasses();
// if there aren't any add this restriction as equivalence class
if(eq == null || eq.length == 0){
OWLIntersectionClass ic = cls.getOWLModel().createOWLIntersectionClass();
ic.addOperand(getResource(res));
((OWLNamedClass)cls).addEquivalentClass(ic);
// if there are some, make a union of them
}else {
// try to find intersection class and add to it
for(int i=0;i<eq.length;i++){
if(eq[i] instanceof OWLIntersectionClass){
((OWLIntersectionClass)eq[i]).addOperand(getResource(res));
return;
}
}
// if we cant find intersection, lets make an intersection with
// existing restrictions
OWLIntersectionClass in = cls.getOWLModel().createOWLIntersectionClass();
for(int i=0;i<eq.length;i++){
in.addOperand(eq[i].createClone());
((OWLNamedClass)cls).removeEquivalentClass(eq[i]);
}
in.addOperand(getResource(res));
((OWLNamedClass)cls).addEquivalentClass(in);
}
}
}