2
在Groovy的@TupleConstructor
註釋,是什麼includeFields
和includeProperties
之間的差異。屬性是否僅包含公共設置者/獲取者和字段包含私有?我找不到與此有關的任何文檔。常規@TupleConstructor includeFields VS includeProperties
在Groovy的@TupleConstructor
註釋,是什麼includeFields
和includeProperties
之間的差異。屬性是否僅包含公共設置者/獲取者和字段包含私有?我找不到與此有關的任何文檔。常規@TupleConstructor includeFields VS includeProperties
一個Groovy場是沒有getter和setter的公共屬性:
@groovy.transform.TupleConstructor(includeFields=false)
class Invoice {
Integer serie, number // properties
BigDecimal total // property
public Integer type // this is a field
}
try {
i = new Invoice(1, 2, 10.0, 10)
assert false
} catch (e) {
assert true
}
感謝澄清。有這方面的文件嗎? – 2013-03-07 20:18:42
http://groovy.codehaus.org/Groovy%2BBeans:「如果使用訪問修飾符(public,private或protected)聲明[屬性]的名稱,則會生成一個字段」。 – Will 2013-03-07 22:07:27
感謝您的鏈接 – 2013-03-07 22:39:14