This commit is contained in:
Timo Westkämper 2009-01-07 12:08:29 +00:00
parent 8d97a0427a
commit 1274c8b0b4
2 changed files with 108 additions and 54 deletions

View File

@ -64,6 +64,17 @@ public class Field implements Comparable<Field> {
public String getName() {
return name;
}
// TODO : improve this name normalization
public String getRealName(){
if (name.equals("prvate")){
return "private";
}else if (name.equals("pblic")){
return "public";
}else{
return name;
}
}
public String getSimpleTypeName() {
return simpleTypeName;

View File

@ -1,71 +1,38 @@
<#macro classContent decl embeddable>
<#assign reserved = ["isnull", "isnotnull", "getType", "getMetadata", "toString", "hashCode", "getClass", "notify", "notifyAll", "wait"]>
<#list decl.stringFields as field>
public final Path.PString ${field.name} = _string("${field.name}");
<#assign reserved = ["isnull", "isnotnull", "getType", "getMetadata", "toString", "hashCode", "getClass", "notify", "notifyAll", "wait"]>
<#macro classContent decl embeddable>
<#list decl.stringFields as field>
<@stringField field=field/>
</#list>
<#list decl.booleanFields as field>
public final Path.PBoolean ${field.name} = _boolean("${field.name}");
</#list>
<#-- simple fields -->
<@booleanField field=field/>
</#list>
<#list decl.simpleFields as field>
public final Path.PSimple<${field.typeName}> ${field.name} = _simple("${field.name}",${field.typeName}.class);
<@simpleField field=field/>
</#list>
<#list decl.comparableFields as field>
public final Path.PComparable<${field.typeName}> ${field.name} = _comparable("${field.name}",${field.typeName}.class);
<@comparableField field=field/>
</#list>
<#list decl.simpleMaps as field>
public final Path.PComponentMap<${field.keyTypeName},${field.typeName}> ${field.name} = _simplemap("${field.name}",${field.keyTypeName}.class,${field.typeName}.class);
public Path.PSimple<${field.typeName}> ${field.name}(${field.keyTypeName} key) {
return new Path.PSimple<${field.typeName}>(${field.typeName}.class,forMapAccess(${field.name},key));
}
public Path.PSimple<${field.typeName}> ${field.name}(Expr<${field.keyTypeName}> key) {
return new Path.PSimple<${field.typeName}>(${field.typeName}.class,forMapAccess(${field.name},key));
}
<@simpleMap field=field/>
</#list>
<#list decl.simpleCollections as field>
public final Path.PComponentCollection<${field.typeName}> ${field.name} = _simplecol("${field.name}",${field.typeName}.class);
<@simpleCollection field=field/>
</#list>
<#list decl.simpleLists as field>
public final Path.PComponentList<${field.typeName}> ${field.name} = _simplelist("${field.name}",${field.typeName}.class);
public Path.PSimple<${field.typeName}> ${field.name}(int index) {
return new Path.PSimple<${field.typeName}>(${field.typeName}.class,forListAccess(${field.name},index));
}
public Path.PSimple<${field.typeName}> ${field.name}(Expr<Integer> index) {
return new Path.PSimple<${field.typeName}>(${field.typeName}.class,forListAccess(${field.name},index));
}
</#list>
<#-- entity fields -->
<@simpleList field=field/>
</#list>
<#list decl.entityMaps as field>
public final Path.PEntityMap<${field.keyTypeName},${field.typeName}> ${field.name} = _entitymap("${field.name}",${field.keyTypeName}.class,${field.typeName}.class);
public ${pre}${field.simpleTypeName} ${field.name}(${field.keyTypeName} key) {
return new ${pre}${field.simpleTypeName}(forMapAccess(${field.name},key));
}
public ${pre}${field.simpleTypeName} ${field.name}(Expr<${field.keyTypeName}> key) {
return new ${pre}${field.simpleTypeName}(forMapAccess(${field.name},key));
}
<@entityMap field=field/>
</#list>
<#list decl.entityCollections as field>
public final Path.PEntityCollection<${field.typeName}> ${field.name} = _entitycol("${field.name}",${field.typeName}.class);
<@entityCollection field=field/>
</#list>
<#list decl.entityLists as field>
public final Path.PEntityList<${field.typeName}> ${field.name} = _entitylist("${field.name}",${field.typeName}.class);
public ${pre}${field.simpleTypeName} ${field.name}(int index) {
return new ${pre}${field.simpleTypeName}(forListAccess(${field.name},index));
}
public ${pre}${field.simpleTypeName} ${field.name}(Expr<Integer> index) {
return new ${pre}${field.simpleTypeName}(forListAccess(${field.name},index));
}
<@entityList field=field/>
</#list>
<#list decl.entityFields as field>
public ${pre}${field.simpleTypeName} ${field.name};
<#if !reserved?seq_contains(field.name)>
public ${pre}${field.simpleTypeName} _${field.name}() {
if (${field.name} == null) ${field.name} = new ${pre}${field.simpleTypeName}(forProperty(this,"${field.name}"));
return ${field.name};
}
</#if>
<@entityField field=field/>
</#list>
<#-- constructors -->
@ -79,7 +46,83 @@
</#list>
}
</#if>
public ${pre}${decl.simpleName}(PathMetadata<?> metadata) {
super(${decl.name}.class, metadata);
}
</#macro>
public ${pre}${decl.simpleName}(PathMetadata<?> metadata) {
super(${decl.name}.class, metadata);
}
</#macro>
<#macro booleanField field>
public final Path.PBoolean ${field.name} = _boolean("${field.realName}");
</#macro>
<#macro comparableField field>
public final Path.PComparable<${field.typeName}> ${field.name} = _comparable("${field.realName}",${field.typeName}.class);
</#macro>
<#macro entityCollection field>
public final Path.PEntityCollection<${field.typeName}> ${field.name} = _entitycol("${field.realName}",${field.typeName}.class);
</#macro>
<#macro entityField field>
public ${pre}${field.simpleTypeName} ${field.name};
<#if !reserved?seq_contains(field.name)>
public ${pre}${field.simpleTypeName} _${field.name}() {
if (${field.name} == null) ${field.name} = new ${pre}${field.simpleTypeName}(forProperty(this,"${field.realName}"));
return ${field.name};
}
</#if>
</#macro>
<#macro entityList field>
public final Path.PEntityList<${field.typeName}> ${field.name} = _entitylist("${field.realName}",${field.typeName}.class);
public ${pre}${field.simpleTypeName} ${field.name}(int index) {
return new ${pre}${field.simpleTypeName}(forListAccess(${field.name},index));
}
public ${pre}${field.simpleTypeName} ${field.name}(Expr<Integer> index) {
return new ${pre}${field.simpleTypeName}(forListAccess(${field.name},index));
}
</#macro>
<#macro entityMap field>
public final Path.PEntityMap<${field.keyTypeName},${field.typeName}> ${field.name} = _entitymap("${field.realName}",${field.keyTypeName}.class,${field.typeName}.class);
public ${pre}${field.simpleTypeName} ${field.name}(${field.keyTypeName} key) {
return new ${pre}${field.simpleTypeName}(forMapAccess(${field.name},key));
}
public ${pre}${field.simpleTypeName} ${field.name}(Expr<${field.keyTypeName}> key) {
return new ${pre}${field.simpleTypeName}(forMapAccess(${field.name},key));
}
</#macro>
<#macro simpleField field>
public final Path.PSimple<${field.typeName}> ${field.name} = _simple("${field.realName}",${field.typeName}.class);
</#macro>
<#macro simpleMap field>
public final Path.PComponentMap<${field.keyTypeName},${field.typeName}> ${field.name} = _simplemap("${field.realName}",${field.keyTypeName}.class,${field.typeName}.class);
public Path.PSimple<${field.typeName}> ${field.name}(${field.keyTypeName} key) {
return new Path.PSimple<${field.typeName}>(${field.typeName}.class,forMapAccess(${field.name},key));
}
public Path.PSimple<${field.typeName}> ${field.name}(Expr<${field.keyTypeName}> key) {
return new Path.PSimple<${field.typeName}>(${field.typeName}.class,forMapAccess(${field.name},key));
}
</#macro>
<#macro simpleCollection field>
public final Path.PComponentCollection<${field.typeName}> ${field.name} = _simplecol("${field.realName}",${field.typeName}.class);
</#macro>
<#macro simpleList field>
public final Path.PComponentList<${field.typeName}> ${field.name} = _simplelist("${field.realName}",${field.typeName}.class);
public Path.PSimple<${field.typeName}> ${field.name}(int index) {
return new Path.PSimple<${field.typeName}>(${field.typeName}.class,forListAccess(${field.name},index));
}
public Path.PSimple<${field.typeName}> ${field.name}(Expr<Integer> index) {
return new Path.PSimple<${field.typeName}>(${field.typeName}.class,forListAccess(${field.name},index));
}
</#macro>
<#macro stringField field>
public final Path.PString ${field.name} = _string("${field.realName}");
</#macro>