Let's do that abstract check up here as well.

This commit is contained in:
Michael Bayne
2007-04-19 21:27:18 +00:00
parent b4051ef67e
commit 17c6e9a2f6
@@ -146,17 +146,20 @@ public class GenRecordTask extends Task
return; return;
} }
// determine which fields make up our primary key; we'd just use Class.getFields() but that // determine our primary key fields for getKey() generation (if we're not an abstract)
// returns things in a random order whereas ClassUtil returns fields in declaration order
// starting from the top-most class and going down the line
List<Field> kflist = new ArrayList<Field>(); List<Field> kflist = new ArrayList<Field>();
FIELD_LOOP: if (!Modifier.isAbstract(oclass.getModifiers())) {
for (Field field : ClassUtil.getFields(oclass)) { // determine which fields make up our primary key; we'd just use Class.getFields() but
// iterate becase getAnnotation() fails if we're dealing with multiple classloaders // that returns things in a random order whereas ClassUtil returns fields in
for (Annotation a : field.getAnnotations()) { // declaration order starting from the top-most class and going down the line
if (Id.class.getName().equals(a.annotationType().getName())) { FIELD_LOOP:
kflist.add(field); for (Field field : ClassUtil.getFields(oclass)) {
continue FIELD_LOOP; // iterate becase getAnnotation() fails if we're dealing with multiple classloaders
for (Annotation a : field.getAnnotations()) {
if (Id.class.getName().equals(a.annotationType().getName())) {
kflist.add(field);
continue FIELD_LOOP;
}
} }
} }
} }
@@ -278,8 +281,8 @@ public class GenRecordTask extends Task
// generate our methods section // generate our methods section
StringBuilder msection = new StringBuilder(); StringBuilder msection = new StringBuilder();
// add a getKey() method, if applicable (and we're not abstract) // add a getKey() method, if applicable
if (!Modifier.isAbstract(oclass.getModifiers()) && kflist.size() > 0) { if (kflist.size() > 0) {
// create our velocity context // create our velocity context
VelocityContext ctx = new VelocityContext(); VelocityContext ctx = new VelocityContext();
ctx.put("record", rname); ctx.put("record", rname);