對於MVC模型類,我的setter方法是這樣的:Eclipse的模板()
enum BoundProperty {FIELD_NAME, ...}
private Type fieldName;
public setFieldName(Type newValue) {
Type oldValue = fieldName;
fieldName = newValue;
firePropertyChange(BoundProperty.FIELD_NAME, oldValue, newValue);
}
給定一個領域,這可以從輸出自動生成的制定者產生?如果沒有,有沒有辦法從模板獲取這個輸出?
輸出結果應該是CamelCase的字段名以產生方法名,所以fieldName生成setFieldName()和Uppercase字段名來產生屬性枚舉。
所以fieldName生成FIELD_NAME
(或FIELDNAME
也可以)。
它看起來像[這個答案](http://stackoverflow.com/a/7237108/274350)做一些我在找的東西。 – 2012-01-17 13:50:21