private void findSuperclassDescriptor() throws MetaDataException { // descriptor for super class for (ClassDescriptor cld : superDescriptors) { if (!cld.isInterface()) { if (this.isInterface()) { throw new MetaDataException("An interface (" + this + " may not have a superclass (" + cld + ")"); } if (superclassDescriptor != null) { throw new MetaDataException("Cannot have multiple superclasses for: " + this); } superclassDescriptor = cld; } } }
private void findSuperclassDescriptor() throws MetaDataException { // descriptor for super class for (ClassDescriptor cld : superDescriptors) { if (!cld.isInterface()) { if (this.isInterface()) { throw new MetaDataException("An interface (" + this + " may not have a superclass (" + cld + ")"); } if (superclassDescriptor != null) { throw new MetaDataException("Cannot have multiple superclasses for: " + this); } superclassDescriptor = cld; } } }
private static String getClassName(Class<?> cls, Model model) { if (cls != null) { ClassDescriptor cld = model.getClassDescriptorByName(cls.getName()); if (cld != null && !cld.isInterface()) { return cld.getName(); } } return ""; }
private static String getClassName(Class<?> cls, Model model) { if (cls != null) { ClassDescriptor cld = model.getClassDescriptorByName(cls.getName()); if (cld != null && !cld.isInterface()) { return cld.getName(); } } return ""; }
/** * Get all interfaces that an object implements. * * @param obj the object * @param model the parent model * @return space separated list of extended/implemented classes/interfaces */ protected static String getImplements(Object obj, Model model) { StringBuffer sb = new StringBuffer(); Class<?>[] interfaces = obj.getClass().getInterfaces(); Arrays.sort(interfaces, new RendererComparator()); for (int i = 0; i < interfaces.length; i++) { ClassDescriptor cld = model.getClassDescriptorByName(interfaces[i].getName()); if (cld != null && cld.isInterface() && !"org.intermine.model.InterMineObject".equals(cld.getName())) { sb.append(TypeUtil.unqualifiedName(interfaces[i].getName())).append(" "); } } return sb.toString().trim(); } }
/** * Get all interfaces that an object implements. * * @param obj the object * @param model the parent model * @return space separated list of extended/implemented classes/interfaces */ protected static String getImplements(Object obj, Model model) { StringBuffer sb = new StringBuffer(); Class<?>[] interfaces = obj.getClass().getInterfaces(); Arrays.sort(interfaces, new RendererComparator()); for (int i = 0; i < interfaces.length; i++) { ClassDescriptor cld = model.getClassDescriptorByName(interfaces[i].getName()); if (cld != null && cld.isInterface() && !"org.intermine.model.InterMineObject".equals(cld.getName())) { sb.append(TypeUtil.unqualifiedName(interfaces[i].getName())).append(" "); } } return sb.toString().trim(); } }
fos.write(generate(cld, false)); fos.close(); if (cld.isInterface()) { path = new File(dir, cls + "Shadow.java"); path.delete();
fos.write(generate(cld, false)); fos.close(); if (cld.isInterface()) { path = new File(dir, cls + "Shadow.java"); path.delete();
.append("public StringConstructor getoBJECT() {\n") .append(INDENT + INDENT) .append("if (!" + cld.getName() + (cld.isInterface() ? "Shadow" : "") + ".class.equals(getClass())) {\n") .append(INDENT + INDENT + INDENT)
.append("public StringConstructor getoBJECT() {\n") .append(INDENT + INDENT) .append("if (!" + cld.getName() + (cld.isInterface() ? "Shadow" : "") + ".class.equals(getClass())) {\n") .append(INDENT + INDENT + INDENT)
if (merge.isInterface() != original.isInterface()) { throw new ModelMergerException("Same class definition found as a class and interface " + original.getName() + ".isInterface/" + original.isInterface() + " != " + merge.getName() + ".isInterface/" + merge.isInterface()); for (String clsName : superNames) { ClassDescriptor cld = originalModel.getClassDescriptorByName(clsName); if (cld != null && !cld.isInterface()) { replacingSuperclass = true; break; if (cld != null && !cld.isInterface()) { replacingSuperclass = true; break; merge.isInterface(), attrs, refs, cols);
if (merge.isInterface() != original.isInterface()) { throw new ModelMergerException("Same class definition found as a class and interface " + original.getName() + ".isInterface/" + original.isInterface() + " != " + merge.getName() + ".isInterface/" + merge.isInterface()); for (String clsName : superNames) { ClassDescriptor cld = originalModel.getClassDescriptorByName(clsName); if (cld != null && !cld.isInterface()) { replacingSuperclass = true; break; if (cld != null && !cld.isInterface()) { replacingSuperclass = true; break; merge.isInterface(), attrs, refs, cols);
.append(";" + ENDL + ENDL); if ((!cld.isInterface()) || shadow) { boolean hasCollections = false; boolean hasReferences = false; .append((cld.isInterface() && (!shadow)) ? "interface " : "class ") .append(TypeUtil.unqualifiedName(cld.getName())) .append(shadow ? "Shadow" : ""); .append(", ShadowClass"); } else { if (!cld.isInterface()) { if (cld.getSuperclassDescriptor() != null) { sb.append(" extends ") if (superCld.isInterface()) { if (firstTime) { sb.append(cld.isInterface() ? " extends " : " implements "); firstTime = false; } else { if (cld.isInterface() && (!shadow)) { sb.append(generateFieldDescriptors(cld, false)); } else {
.append(";" + ENDL + ENDL); if ((!cld.isInterface()) || shadow) { boolean hasCollections = false; boolean hasReferences = false; .append((cld.isInterface() && (!shadow)) ? "interface " : "class ") .append(TypeUtil.unqualifiedName(cld.getName())) .append(shadow ? "Shadow" : ""); .append(", ShadowClass"); } else { if (!cld.isInterface()) { if (cld.getSuperclassDescriptor() != null) { sb.append(" extends ") if (superCld.isInterface()) { if (firstTime) { sb.append(cld.isInterface() ? " extends " : " implements "); firstTime = false; } else { if (cld.isInterface() && (!shadow)) { sb.append(generateFieldDescriptors(cld, false)); } else {
parents.add(parent.substring(parent.lastIndexOf(".") + 1)); classData.put("isInterface", cld.isInterface()); classData.put("attributes", attrs); classData.put("references", refs);
parents.add(parent.substring(parent.lastIndexOf(".") + 1)); classData.put("isInterface", cld.isInterface()); classData.put("attributes", attrs); classData.put("references", refs);
/** * Construct a ClassDescriptor that takes on all the properties of <code>cld</code> * without attaching to a particular Model. * * @param cld the ClassDescriptor to clone * @return cloned ClassDescriptor */ protected static ClassDescriptor cloneClassDescriptor(ClassDescriptor cld) { // supers can't be an empty string String supers = StringUtil.join(cld.getSuperclassNames(), " "); if (supers != null && "".equals(supers)) { supers = null; } return new ClassDescriptor(cld.getName(), supers, cld.isInterface(), cloneAttributeDescriptors(cld.getAttributeDescriptors()), cloneReferenceDescriptors(cld.getReferenceDescriptors()), cloneCollectionDescriptors(cld.getCollectionDescriptors())); }
/** * Construct a ClassDescriptor that takes on all the properties of <code>cld</code> * without attaching to a particular Model. * * @param cld the ClassDescriptor to clone * @return cloned ClassDescriptor */ protected static ClassDescriptor cloneClassDescriptor(ClassDescriptor cld) { // supers can't be an empty string String supers = StringUtil.join(cld.getSuperclassNames(), " "); if (supers != null && "".equals(supers)) { supers = null; } return new ClassDescriptor(cld.getName(), supers, cld.isInterface(), cloneAttributeDescriptors(cld.getAttributeDescriptors()), cloneReferenceDescriptors(cld.getReferenceDescriptors()), cloneCollectionDescriptors(cld.getCollectionDescriptors())); }
newSet.put(cd.getName(), new ClassDescriptor(cd.getName(), supersStr, cd.isInterface(), cloneAttributeDescriptors(adescs), cloneReferenceDescriptors(rdescs),
newSet.put(cd.getName(), new ClassDescriptor(cd.getName(), supersStr, cd.isInterface(), cloneAttributeDescriptors(adescs), cloneReferenceDescriptors(rdescs),