You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "Zezeng Wang (Jira)" <ji...@apache.org> on 2019/10/12 09:30:00 UTC

[jira] [Commented] (AVRO-2419) Generate private attribute in Java

    [ https://issues.apache.org/jira/browse/AVRO-2419?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16949976#comment-16949976 ] 

Zezeng Wang commented on AVRO-2419:
-----------------------------------

[~khuynhthanhchiluyen]
Hey, huslsls, have you found a solution?
I suggest you raise the avro version to 1.9.0, because after avro-1.9.0, the generated java class attribute has defaulted to private, but unfortunately, if you use avro-tools, it does not support setting fieldvisibility. Value function


> Generate private attribute in Java
> ----------------------------------
>
>                 Key: AVRO-2419
>                 URL: https://issues.apache.org/jira/browse/AVRO-2419
>             Project: Apache Avro
>          Issue Type: Wish
>          Components: java
>    Affects Versions: 1.7.7
>            Reporter: khuynhthanhchiluyen
>            Priority: Major
>
> I used file user.avsc like below:
> {  
>     "namespace":"example.avro",
>     "type":"record",
>     "name":"User",
>     "fields":[  
>        
> {            "name":"name",          "type":"string"       }
> ,
>        
> {            "name":"favorite_number",          "type":[               "int",             "null"          ]       }
> ,
>        
> {            "name":"favorite_color",          "type":[               "string",             "null"          ]       }
>    ]
>  }
>  
> And I used avro-1.7.7.jar to generate my Java code:
> java -jar java -jar avro-tools-1.7.7.jar compile -string schema user.avsc D:\result
>  
> But all attributes of User class (name, favorite_number, favorite_color) appear to be "public". Where did I miss to make them private (for encapsulation). Thank you very much.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)