2

groovy の注釈では、と@TupleConstructorの違いは何ですか。プロパティにはパブリック セッター/ゲッターのみが含まれ、フィールドにはプライベートが含まれますか? これに関するドキュメントは見つかりませんでした。includeFieldsincludeProperties

4

1 に答える 1

4

Groovyフィールドは、ゲッターとセッターのない公共施設です。

@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-07T20:12:30.357 に答える