本文整理了Java中org.intermine.metadata.Model.<init>()
方法的一些代码示例,展示了Model.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Model.<init>()
方法的具体详情如下:
包路径:org.intermine.metadata.Model
类名称:Model
方法名:<init>
[英]Construct a Model with a name and set of ClassDescriptors. The model will be set to this in each of the ClassDescriptors. NB This method should only be called by members of the modelproduction package, eventually it may be replaced with a static addModel method linked to getInstanceByName.
[中]用一个名称和一组类描述符构造一个模型。模型将在每个类描述符中设置为这个。注意:此方法只能由modelproduction包的成员调用,最终可能会被链接到getInstanceByName的静态addModel方法替换。
代码示例来源:origin: intermine/intermine
public void testGenerateHashCode() throws Exception {
ClassDescriptor cld1 = new ClassDescriptor("package.name.Class1", null, false, new HashSet(), new HashSet(), new HashSet());
Model model = new Model("model", "package.name", new HashSet(Collections.singleton(cld1)));
String expected = INDENT + "@Override public int hashCode() { return (id != null) ? id.hashCode() : super.hashCode(); }" + ENDL;
assertEquals(expected, mo.generateHashCode(cld1));
}
代码示例来源:origin: intermine/intermine
public void testGenerateAttributeDescriptor() throws Exception {
AttributeDescriptor atd1 = new AttributeDescriptor("atd1", "java.lang.String");
Set atts = new HashSet(Collections.singleton(atd1));
ClassDescriptor cld1 = new ClassDescriptor("Class1", null, false, atts, new HashSet(), new HashSet());
Model model = new Model("model", "", new HashSet(Collections.singleton(cld1)));
String expected = INDENT + "// Attr: Class1.atd1" + ENDL
+ INDENT + "protected java.lang.String atd1;" + ENDL
+ INDENT + "public java.lang.String getAtd1() { return atd1; }" + ENDL
+ INDENT + "public void setAtd1(final java.lang.String atd1) { this.atd1 = atd1; }" + ENDL + ENDL;
assertEquals(expected, mo.generate(atd1, true));
}
代码示例来源:origin: intermine/intermine
public void testGenerateGetSet() throws Exception {
AttributeDescriptor atd1 = new AttributeDescriptor("atd1", "java.lang.String");
Set atts = new HashSet(Collections.singleton(atd1));
ClassDescriptor cld1 = new ClassDescriptor("Class1", null, false, atts, new HashSet(), new HashSet());
Model model = new Model("model", "", new HashSet(Collections.singleton(cld1)));
String expected = INDENT + "public java.lang.String getAtd1() { return atd1; }" + ENDL
+ INDENT + "public void setAtd1(final java.lang.String atd1) { this.atd1 = atd1; }" + ENDL;
assertEquals(expected, mo.generateGetSet(atd1, true));
}
代码示例来源:origin: intermine/intermine
public void testSimpleObjectClassDescriptors() throws Exception {
ClassDescriptor simpleObjectCld = makeClass("package.name.Simple", "java.lang.Object");
new Model("test", "package.name", Collections.singleton(simpleObjectCld));
Set<String> expected = Collections.singleton("java.lang.Object");
assertEquals(expected, simpleObjectCld.getSuperclassNames());
}
代码示例来源:origin: intermine/intermine
public void testRelationTypeManyToMany() throws Exception {
CollectionDescriptor col1 = new CollectionDescriptor("col1", "package.name.Class1", "col2");
CollectionDescriptor col2 = new CollectionDescriptor("col2", "package.name.Class1", null);
Set<CollectionDescriptor> cols = new HashSet<CollectionDescriptor>(Arrays.asList(col1, col2));
ClassDescriptor cld = new ClassDescriptor("package.name.Class1", null, false, noAttrs, noRefs, cols);
new Model("model1", "package.name", Collections.singleton(cld));
assertEquals(FieldDescriptor.M_N_RELATION, col1.relationType());
}
代码示例来源:origin: intermine/intermine
public void testRelationTypeUnidirectional() throws Exception {
CollectionDescriptor col = new CollectionDescriptor("col1", "package.name.Class1", null);
Set<CollectionDescriptor> cols = Collections.singleton(col);
ClassDescriptor cld = new ClassDescriptor("package.name.Class1", null, false, noAttrs, noRefs, cols);
new Model("model1", "package.name", Collections.singleton(cld));
assertEquals(FieldDescriptor.M_N_RELATION, col.relationType());
}
代码示例来源:origin: intermine/intermine
public void testRelationTypeUnidirectional() throws Exception {
ReferenceDescriptor ref = new ReferenceDescriptor("ref1", "package.name.Class1", null);
ClassDescriptor cld = new ClassDescriptor("package.name.Class1", null, false,
ClassDescriptorFactory.NO_ATTRS, Collections.singleton(ref), ClassDescriptorFactory.NO_COLLS);
new Model("model1", "package.name", Collections.singleton(cld));
assertEquals(FieldDescriptor.N_ONE_RELATION, ref.relationType());
}
代码示例来源:origin: intermine/intermine
public void testRelationTypeOneToMany() throws Exception {
CollectionDescriptor col = new CollectionDescriptor("col1", "package.name.Class1", "ref1");
ReferenceDescriptor ref = new ReferenceDescriptor("ref1", "package.name.Class1", null);
Set<CollectionDescriptor> cols = Collections.singleton(col);
Set<ReferenceDescriptor> refs = Collections.singleton(ref);
ClassDescriptor cld = new ClassDescriptor("package.name.Class1", null, false, noAttrs, refs, cols);
new Model("model1", "package.name", Collections.singleton(cld));
assertEquals(FieldDescriptor.ONE_N_RELATION, col.relationType());
}
代码示例来源:origin: intermine/intermine
public void testEquals() throws Exception {
String packageName = cdMaker.getPackageName();
Model m1 = new Model("flibble", packageName, noClasses);
Model m2 = new Model("flibble", packageName, noClasses);
Model m3 = new Model("flobble", packageName, noClasses);
Model m4 = new Model("flibble", packageName, Collections.singleton(cdMaker.makeClass("Class1")));
assertEquals(m1, m2);
assertEquals(m1.hashCode(), m2.hashCode());
assertFalse(m1.equals(m3));
assertTrue(!m1.equals(m3));
assertTrue(!m1.equals(m4));
}
代码示例来源:origin: intermine/intermine
public void testMultipleSuperClass() throws Exception {
ClassDescriptor superCld1 = makeClass("package.name.superCld1");
ClassDescriptor superCld2 = makeClass("package.name.superCld2");
ClassDescriptor cld = makeClass("package.name.cld", "package.name.superCld1 package.name.superCld2");
try {
new Model("test", "package.name", Arrays.asList(cld, superCld1, superCld2));
fail("Expected: MetaDataException");
} catch (MetaDataException e) {
}
}
代码示例来源:origin: intermine/intermine
public void testInterfaceNotImplemented() throws MetaDataException {
ClassDescriptor cld1 = makeInterface("package.name.Interface1");
Model model = new Model("model", "package.name", Collections.singleton(cld1));
assertTrue(model.getClassDescriptorByName(cld1.getName()).getSubDescriptors().size() == 0);
}
代码示例来源:origin: intermine/intermine
public void testSuperClassExists() throws MetaDataException {
ClassDescriptor superCld = makeClass("package.name.superCld");
ClassDescriptor cld = makeClass("package.name.cld", "package.name.superCld");
new Model("test", "package.name", Arrays.asList(cld, superCld));
assertEquals(superCld, cld.getSuperclassDescriptor());
}
代码示例来源:origin: intermine/intermine
public void testProcess() throws Exception {
Model model = parser.process(new StringReader(getModelXml()));
Model expected = new Model("testmodel", "org.intermine.model.testmodel",
getExpectedClds());
assertEquals(expected, model);
}
代码示例来源:origin: intermine/intermine
public void testGetImplementorDescriptors() throws Exception {
ClassDescriptor cld1 = makeInterface("package.name.Interface1");
ClassDescriptor cld2 = makeClass("package.name.Class2", "package.name.Interface1");
ClassDescriptor cld3 = makeClass("package.name.Class3", "package.name.Interface1");
ClassDescriptor cld4 = makeClass("package.name.Class4", "package.name.Class2");
new Model("test2", "package.name", Arrays.asList(cld1, cld2, cld3, cld4));
// getImplementorDescriptrors should just return direct implementations (cld2, cld3)
Set<ClassDescriptor> impls = new HashSet<ClassDescriptor>(Arrays.asList(cld2, cld3));
assertEquals(impls, cld1.getSubDescriptors());
}
代码示例来源:origin: intermine/intermine
public void testRemoveRedundantInterfaces() throws MetaDataException {
String packageName = cdMaker.getPackageName();
ClassDescriptor base = cdMaker.makeInterface("BaseClass");
ClassDescriptor sub = cdMaker.makeInterface("SubClass", "BaseClass", "MidClass");
ClassDescriptor mid = cdMaker.makeInterface("MidClass", "BaseClass");
Model model = new Model("model", packageName, Arrays.asList(base, sub, mid));
ClassDescriptor subCD = model.getClassDescriptorByName("SubClass");
assertEquals(1, subCD.getSuperclassNames().size());
assertEquals(packageName + ".MidClass", subCD.getSuperclassNames().iterator().next());
}
代码示例来源:origin: intermine/intermine
public void testToString() throws Exception {
String packageName = cdMaker.getPackageName();
ClassDescriptor cld1 = cdMaker.makeClass("Class1");
ClassDescriptor cld2 = cdMaker.makeClass("Class2");
Model model = new Model("model", packageName, Arrays.asList(cld1, cld2));
String expected = "<model name=\"model\" package=\"" + packageName + "\">" + ENDL
+ "<class name=\"Class1\" is-interface=\"false\"></class>" + ENDL
+ "<class name=\"Class2\" is-interface=\"false\"></class>" + ENDL
+ "</model>";
assertEquals(expected, model.toString());
}
代码示例来源:origin: intermine/intermine
public void testRemoveRedundantClasses() throws MetaDataException {
String packageName = cdMaker.getPackageName();
ClassDescriptor base = cdMaker.makeClass("BaseClass");
ClassDescriptor sub = cdMaker.makeClass("SubClass", "BaseClass", "MidClass");
ClassDescriptor mid = cdMaker.makeClass("MidClass", "BaseClass");
Model model = new Model("model", packageName, Arrays.asList(base, sub, mid));
ClassDescriptor subCD = model.getClassDescriptorByName("SubClass");
assertEquals(1, subCD.getSuperclassNames().size());
assertEquals(packageName + ".MidClass", subCD.getSuperclassNames().iterator().next());
}
代码示例来源:origin: intermine/intermine
public void testRemoveRedundantMixed() throws MetaDataException {
String packageName = cdMaker.getPackageName();
ClassDescriptor base = cdMaker.makeInterface("BaseClass");
ClassDescriptor sub = cdMaker.makeClass("SubClass", "BaseClass", "MidClass");
ClassDescriptor mid = cdMaker.makeInterface("MidClass", "BaseClass");
Model model = new Model("model", packageName, Arrays.asList(base, sub, mid));
ClassDescriptor subCD = model.getClassDescriptorByName("SubClass");
assertEquals(1, subCD.getSuperclassNames().size());
assertEquals(packageName + ".MidClass", subCD.getSuperclassNames().iterator().next());
}
代码示例来源:origin: intermine/intermine
public void testToString() throws Exception {
ClassDescriptor cld1 = makeInterface("package.name.Interface1");
ClassDescriptor cld2 = makeClass("package.name.Class2");
ClassDescriptor cld3 = makeClass("package.name.Class3", "package.name.Class2 package.name.Interface1");
String expected =
"<class name=\"Class3\" extends=\"Class2 Interface1\" is-interface=\"false\"></class>" + ENDL;
new Model("test", "package.name", Arrays.asList(cld1, cld2, cld3));
assertEquals(expected, cld3.toString());
}
代码示例来源:origin: intermine/intermine
public void testMultiInheritanceLegalRef() throws Exception {
ReferenceDescriptor ref1 = new ReferenceDescriptor("atd1", "package.name.Class2", null);
ReferenceDescriptor ref2 = new ReferenceDescriptor("atd1", "package.name.Class2", null);
Set<ReferenceDescriptor> refs1 = Collections.singleton(ref1);
Set<ReferenceDescriptor> refs2 = Collections.singleton(ref2);
ClassDescriptor cld1 = new ClassDescriptor("package.name.Class1", null, true, noAttrs, refs1, noColls);
ClassDescriptor cld2 = new ClassDescriptor("package.name.Class2", null, true, noAttrs, refs2, noColls);
ClassDescriptor cld3 = makeClass("package.name.Class3", "package.name.Class1 package.name.Class2");
new Model("model", "package.name", Arrays.asList(cld1, cld2, cld3));
ReferenceDescriptor rd = cld3.getReferenceDescriptorByName("atd1", true);
assertEquals("package.name.Class2", rd.getReferencedClassName());
}
内容来源于网络,如有侵权,请联系作者删除!