protected <T extends OWLProperty> SortedSet<T> getSubPropertiesImpl(T role) throws ReasoningMethodUnsupportedException { if(OWLObjectProperty.class.isInstance(role)) { return (SortedSet<T>) getSubPropertiesImpl((OWLObjectProperty) role); } else if(OWLDataProperty.class.isInstance(role)) { return (SortedSet<T>) getSubPropertiesImpl((OWLDataProperty) role); } throw new ReasoningMethodUnsupportedException(); }
/** * Creates the object property hierarchy. Invoking this method is optional * (if not called explicitly, it is called the first time, it is needed). * * @return The object property hierarchy. * @throws ReasoningMethodUnsupportedException * Thrown if a reasoning method for object property * hierarchy creation is not supported by the reasoner. */ public ObjectPropertyHierarchy prepareObjectPropertyHierarchy() throws ReasoningMethodUnsupportedException { TreeMap<OWLObjectProperty, SortedSet<OWLObjectProperty>> roleHierarchyUp = new TreeMap<>( ); TreeMap<OWLObjectProperty, SortedSet<OWLObjectProperty>> roleHierarchyDown = new TreeMap<>( ); Set<OWLObjectProperty> atomicRoles = getObjectProperties(); for (OWLObjectProperty role : atomicRoles) { roleHierarchyDown.put(role, getSubPropertiesImpl(role)); roleHierarchyUp.put(role, getSuperPropertiesImpl(role)); } roleHierarchy = new ObjectPropertyHierarchy(roleHierarchyUp, roleHierarchyDown); return roleHierarchy; }
/** * Creates the data property hierarchy. Invoking this method is optional (if * not called explicitly, it is called the first time, it is needed). * * @return The data property hierarchy. * @throws ReasoningMethodUnsupportedException * Thrown if data property hierarchy creation is not supported * by the reasoner. */ public DatatypePropertyHierarchy prepareDatatypePropertyHierarchy() throws ReasoningMethodUnsupportedException { TreeMap<OWLDataProperty, SortedSet<OWLDataProperty>> datatypePropertyHierarchyUp = new TreeMap<>( ); TreeMap<OWLDataProperty, SortedSet<OWLDataProperty>> datatypePropertyHierarchyDown = new TreeMap<>( ); Set<OWLDataProperty> datatypeProperties = getDatatypeProperties(); for (OWLDataProperty role : datatypeProperties) { datatypePropertyHierarchyDown.put(role, getSubPropertiesImpl(role)); datatypePropertyHierarchyUp.put(role, getSuperPropertiesImpl(role)); } return new DatatypePropertyHierarchy(datatypePropertyHierarchyUp, datatypePropertyHierarchyDown); }
@Override public final <T extends OWLProperty> SortedSet<T> getSubProperties(T role) { if(OWLObjectProperty.class.isInstance(role) && precomputeObjectPropertyHierarchy) { return (SortedSet<T>) getObjectPropertyHierarchy().getMoreSpecialRoles((OWLObjectProperty) role); } else if(OWLDataProperty.class.isInstance(role) && precomputeDataPropertyHierarchy) { return (SortedSet<T>) getDatatypePropertyHierarchy().getMoreSpecialRoles((OWLDataProperty) role); } else { try { return getSubPropertiesImpl(role); } catch (ReasoningMethodUnsupportedException e) { e.printStackTrace(); } } return null; }