org.intermine.metadata.Model.getDirectSubs()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(3.1k)|赞(0)|评价(0)|浏览(175)

本文整理了Java中org.intermine.metadata.Model.getDirectSubs()方法的一些代码示例,展示了Model.getDirectSubs()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Model.getDirectSubs()方法的具体详情如下:
包路径:org.intermine.metadata.Model
类名称:Model
方法名:getDirectSubs

Model.getDirectSubs介绍

[英]Get the ClassDescriptors for the direct subclasses of a class
[中]获取类的直接子类的类描述符

代码示例

代码示例来源:origin: org.intermine/intermine-model

/**
 * Return a Set of ClassDescriptors for all classes that directly extend or implement this class
 * or interface.
 *
 * @return set of subclass ClassDescriptors
 * @throws IllegalStateException if the set of subclasses has not been set
 */
public Set<ClassDescriptor> getSubDescriptors() {
  checkModel();
  return model.getDirectSubs(this);
}

代码示例来源:origin: intermine/intermine

/**
 * Return a Set of ClassDescriptors for all classes that directly extend or implement this class
 * or interface.
 *
 * @return set of subclass ClassDescriptors
 * @throws IllegalStateException if the set of subclasses has not been set
 */
public Set<ClassDescriptor> getSubDescriptors() {
  checkModel();
  return model.getDirectSubs(this);
}

代码示例来源:origin: intermine/intermine

/**
 * Get the ClassDescriptors for the all subclasses of a class
 * @param cld the parent ClassDescriptor
 * @return the ClassDescriptors of all descedents
 */
public Set<ClassDescriptor> getAllSubs(ClassDescriptor cld) {
  Set<ClassDescriptor> returnSubs = new TreeSet<ClassDescriptor>();
  Set<ClassDescriptor> directSubs = getDirectSubs(cld);
  returnSubs.addAll(directSubs);
  for (ClassDescriptor sub : directSubs) {
    returnSubs.addAll(getAllSubs(sub));
  }
  return returnSubs;
}

代码示例来源:origin: org.intermine/intermine-model

/**
 * Get the ClassDescriptors for the all subclasses of a class
 * @param cld the parent ClassDescriptor
 * @return the ClassDescriptors of all descedents
 */
public Set<ClassDescriptor> getAllSubs(ClassDescriptor cld) {
  Set<ClassDescriptor> returnSubs = new TreeSet<ClassDescriptor>();
  Set<ClassDescriptor> directSubs = getDirectSubs(cld);
  returnSubs.addAll(directSubs);
  for (ClassDescriptor sub : directSubs) {
    returnSubs.addAll(getAllSubs(sub));
  }
  return returnSubs;
}

代码示例来源:origin: intermine/intermine

public void testGetDirectSubs() throws Exception {
  Model model = Model.getInstanceByName("basicmodel");
  Set<ClassDescriptor> hasAddressCds =
    model.getClassDescriptorsForClass(org.intermine.model.basicmodel.Thing.class);
  assertEquals(1, hasAddressCds.size());
  ClassDescriptor addressCld = (ClassDescriptor) hasAddressCds.iterator().next();
  if (addressCld.getName() == "org.intermine.model.InterMineObject") {
    // we want org.intermine.model.basicmodel.HasAddress
    addressCld = (ClassDescriptor) hasAddressCds.iterator().next();
  }
  Set<ClassDescriptor> resultCds = model.getDirectSubs(addressCld);
  Set<String> expectedCdNames = new HashSet<String>();
  expectedCdNames.add("org.intermine.model.basicmodel.Employable");
  expectedCdNames.add("org.intermine.model.basicmodel.Address");
  expectedCdNames.add("org.intermine.model.basicmodel.Department");
  Set<String> resultCdNames = new HashSet<String>();
  for (ClassDescriptor cld : resultCds) {
    resultCdNames.add(cld.getName());
  }
  assertEquals(expectedCdNames, resultCdNames);
}

相关文章