} else {
// Add domains to union class
OntResource domain = objectProperty.getDomain();
if (domain != null) {
if (domain.isClass() && domain.asClass().isUnionClass()) {
UnionClass unclass = domain.asClass().asUnionClass();
for (Resource newDomain : domains) {
unclass.addOperand(newDomain);
}
} else {
List<Resource> resources = new ArrayList<Resource>(domains);
resources.add(domain);
objectProperty.setDomain(createUnionClass(resources));
}
}
// Add ranges to union class
OntResource range = objectProperty.getRange();
if (range != null) {
if (range.isClass() && range.asClass().isUnionClass()) {
UnionClass unclass = range.asClass().asUnionClass();
for (Resource newRange : ranges) {
unclass.addOperand(newRange);
}
} else {
List<Resource> resources = new ArrayList<Resource>(ranges);
resources.add(range);
objectProperty.setDomain(createUnionClass(resources));