私は freemarker の初心者で、これを使用して繰り返しコードを生成したいと考えています。
このような単純なクラスから:
public class Point {
private Integer x;
private Integer y;
private String name;
}
属性ごとに、次のような行を生成する必要があります。
ValueProvider<Point,Integer> x();
ValueProvider<Point,Integer> y();
ValueProvider<Point,String> name();
これを達成するために、私はこの単純なテンプレートを持っています:
ValueProvider<${clazz},${attrType}> ${attrName}();
次に、次のような完全なクラスを生成します。
public final class PointValueProviders {
public interface PointPropertyAccess extends PropertyAccess<Point>{
ValueProvider<Point,Integer> x();
ValueProvider<Point,Integer> y();
ValueProvider<Point,String> name();
}
public static final PointPropertyAccess POINT_PA= GWT.create(PointPropertyAccess.class);
private PointValueProviders(){}
};
このために、私は問題を抱えています:私は、このような大きなテンプレートで小さなテンプレートを未定の回数適用する方法がわかりません:
public final ${clazz}ValueProviders {
public interface ${clazz}PropertyAccess extends PropertyAccess<${clazz}>{
//Here, How do I tell freemarker to use the small template???
//ValueProvider<${clazz},${attrType}> ${attrName}();
//ValueProvider<${clazz},${attrType}> ${attrName}();
//ValueProvider<${clazz},${attrType}> ${attrName}();
//ValueProvider<${clazz},${attrType}> ${attrName}();
//etc..
}
public static final ${clazz}PropertyAccess ${clazzUpperCase}_PA= GWT.create(${clazz}PropertyAccess.class);
private ${clazz}ValueProviders(){}
};
何か案が?