[
https://issues.apache.org/jira/browse/AVRO-784?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13009228#comment-13009228
]
E. Sammer commented on AVRO-784:
--------------------------------
{quote}appending get/set onto the front of field names may result in name
conflicts. For example, a record may have fields named both 'setSize' and
'size'. For other generated names we include a dollar sign, a character that is
not permitted in Avro names. My preference here would be to generate, for a
field named 'foo', a 'foo()' getter and a 'foo(x)' setter.{quote}
The prepending, in the case of similarly named fields, would simply result in
'setSetSize(sizeSize)' which would probably be as the user intended. This
should be fine.
The rationale for adhering to the javabean style accessors is that many
frameworks and libraries already grok these names during reflection. For
instance, Spring takes advantage of this for automatic resolution of names of
properties all over the place.
Would you be willing to accept these conventions? Also, if you don't think this
makes sense, would it be acceptable to create an annotation / json property
that results in generated accessor so users have the choice? i.e.
{code}
record {
@get @set int foo;
string inacessableType;
}
{code}
or similar?
{quote}we don't need to generate calls to the 'put' and 'get' methods but can
directly set/get the fields.{quote}
Wasn't sure if that was OK. Sounds good.
{quote}If we directly access the fields then we should use javaUnbox instead of
javaType, so that, e.g., the setter for an int field accepts an "int" paramter
rather than an "Integer".{quote}
Makes sense.
{quote}we should ideally generate javadoc for the setter/getters. if the field
in the schema has documentation then we should include that, otherwise perhaps
generate some vanilla javadoc.{quote}
No problem.
> SpecificCompiler should generate accessors
> ------------------------------------------
>
> Key: AVRO-784
> URL: https://issues.apache.org/jira/browse/AVRO-784
> Project: Avro
> Issue Type: Improvement
> Components: java
> Affects Versions: 1.5.0
> Reporter: E. Sammer
> Labels: features
> Attachments: avro-784.diff
>
>
> Avro's Java SpecificCompiler should generate java bean style accessors.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira