/** * Generates code for a single collection. * * @param col the CollectionDescriptor * @param field true if the class should have the associated field, or false if the field is in * the superclass * @return java code */ protected String generate(CollectionDescriptor col, boolean field) { String type = "java.util.Set<" + col.getReferencedClassName() + ">"; String impl = "java.util.HashSet<" + col.getReferencedClassName() + ">"; StringBuffer sb = new StringBuffer(); if (field) { sb.append(INDENT + "// Col: " + col.getClassDescriptor().getName() + "." + col.getName() + ENDL) .append(INDENT) .append("protected ") .append(type) .append(" ") .append(col.getName()) .append(" = new ") .append(impl) .append("();" + ENDL); } sb.append(generateGetSet(col, field)) .append(ENDL); return sb.toString(); }
/** * Generates code for a single collection. * * @param col the CollectionDescriptor * @param field true if the class should have the associated field, or false if the field is in * the superclass * @return java code */ protected String generate(CollectionDescriptor col, boolean field) { String type = "java.util.Set<" + col.getReferencedClassName() + ">"; String impl = "java.util.HashSet<" + col.getReferencedClassName() + ">"; StringBuffer sb = new StringBuffer(); if (field) { sb.append(INDENT + "// Col: " + col.getClassDescriptor().getName() + "." + col.getName() + ENDL) .append(INDENT) .append("protected ") .append(type) .append(" ") .append(col.getName()) .append(" = new ") .append(impl) .append("();" + ENDL); } sb.append(generateGetSet(col, field)) .append(ENDL); return sb.toString(); }
/** * Creates a column name for the "outward" key of a many-to-many collection descriptor. * * @param col CollectionDescriptor * @param version the database version number * @return a valid column name */ public static String getOutwardIndirectionColumnName(CollectionDescriptor col, int version) { if (FieldDescriptor.M_N_RELATION != col.relationType()) { throw new IllegalArgumentException("Argument must be a CollectionDescriptor for a " + "many-to-many relation"); } if (version == 0) { ReferenceDescriptor rd = col.getReverseReferenceDescriptor(); String colName = (rd == null ? TypeUtil.unqualifiedName(col.getClassDescriptor().getName()) : rd.getName()); return StringUtil.capitalise(generateSqlCompatibleName(colName)); } else if (version == 1) { return StringUtil.capitalise(generateSqlCompatibleName(col.getName())); } else { throw new IllegalArgumentException("Database version number " + version + " not recognised"); } }
/** * Creates a column name for the "outward" key of a many-to-many collection descriptor. * * @param col CollectionDescriptor * @param version the database version number * @return a valid column name */ public static String getOutwardIndirectionColumnName(CollectionDescriptor col, int version) { if (FieldDescriptor.M_N_RELATION != col.relationType()) { throw new IllegalArgumentException("Argument must be a CollectionDescriptor for a " + "many-to-many relation"); } if (version == 0) { ReferenceDescriptor rd = col.getReverseReferenceDescriptor(); String colName = (rd == null ? TypeUtil.unqualifiedName(col.getClassDescriptor().getName()) : rd.getName()); return StringUtil.capitalise(generateSqlCompatibleName(colName)); } else if (version == 1) { return StringUtil.capitalise(generateSqlCompatibleName(col.getName())); } else { throw new IllegalArgumentException("Database version number " + version + " not recognised"); } }
/** * Creates a column name for the "inward" key of a many-to-many collection descriptor. * * @param col CollectionDescriptor * @param version the database version number * @return a valid column name */ public static String getInwardIndirectionColumnName(CollectionDescriptor col, int version) { if (FieldDescriptor.M_N_RELATION != col.relationType()) { throw new IllegalArgumentException("Argument must be a CollectionDescriptor for a " + "many-to-many relation"); } if (version == 0) { return StringUtil.capitalise(generateSqlCompatibleName(col.getName())); } else if (version == 1) { ReferenceDescriptor rd = col.getReverseReferenceDescriptor(); String colName = (rd == null ? TypeUtil.unqualifiedName(col.getClassDescriptor().getName()) : rd.getName()); return StringUtil.capitalise(generateSqlCompatibleName(colName)); } else { throw new IllegalArgumentException("Database version number " + version + " not recognised"); } }
/** * Creates a column name for the "inward" key of a many-to-many collection descriptor. * * @param col CollectionDescriptor * @param version the database version number * @return a valid column name */ public static String getInwardIndirectionColumnName(CollectionDescriptor col, int version) { if (FieldDescriptor.M_N_RELATION != col.relationType()) { throw new IllegalArgumentException("Argument must be a CollectionDescriptor for a " + "many-to-many relation"); } if (version == 0) { return StringUtil.capitalise(generateSqlCompatibleName(col.getName())); } else if (version == 1) { ReferenceDescriptor rd = col.getReverseReferenceDescriptor(); String colName = (rd == null ? TypeUtil.unqualifiedName(col.getClassDescriptor().getName()) : rd.getName()); return StringUtil.capitalise(generateSqlCompatibleName(colName)); } else { throw new IllegalArgumentException("Database version number " + version + " not recognised"); } }
ClassDescriptor cld = desc.getClassDescriptor(); table.addRow(new String[] {desc.getName(), "collection of " + terseClass(desc.getReferencedClassName()),
ClassDescriptor cld = desc.getClassDescriptor(); table.addRow(new String[] {desc.getName(), "collection of " + terseClass(desc.getReferencedClassName()),