class LocalOntology implements Ontology {

  @Override
  public Iterator<String> subclasses(String entitySearchTerm) {
    Map<OntResource, String> classMap = retrieve(entitySearchTerm);
    Map<String, String> subclasses = new HashMap<>();

    Iterator<OntResource> iter = classMap.keySet().iterator();
    while (iter.hasNext()) {
      OntResource resource = iter.next();

      if (resource instanceof OntClass) {
        //get subclasses N.B. we only get direct sub-classes e.g. direct children
        //it is possible for us to navigate the entire class tree if we wish, we simply
        //need to pass the .listSubClasses(true) boolean parameter.
        for (Iterator<?> i = ((OntClass) resource).listSubClasses(); i.hasNext();) {
          OntResource subclass = (OntResource) i.next();
          for (Iterator<?> j = subclass.listLabels(null); j.hasNext();) {
            Literal l = (Literal) j.next();
            subclasses.put(l.toString(), "1");
          }
        }
        //get individuals
        for (Iterator<?> i = ((OntClass) resource).listInstances(); i.hasNext(); ) {
          OntResource subclass = (OntResource) i.next();
          for (Iterator<?> j = subclass.listLabels(null); j.hasNext();) {
            Literal l = (Literal) j.next();
            subclasses.put(l.toString(), "1");
          }
        }
      } else if (resource instanceof Individual) {
        for (Iterator<?> i = resource.listSameAs(); i.hasNext();) {
          OntResource subclass = (OntResource) i.next();
          for (Iterator<?> j = subclass.listLabels(null); j.hasNext();) {
            Literal l = (Literal) j.next();
            subclasses.put(l.toString(), "1");
          }
        }
      }
    }
    return subclasses.keySet().iterator();
  }

  public  LocalOntology();

}