[ 
https://issues.apache.org/jira/browse/AVRO-2419?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

khuynhthanhchiluyen updated AVRO-2419:
--------------------------------------
    Description: 
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 attribute (for 
encapsulation). Thank you very much.

  was:
I use 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 attribute (for 
encapsulation). Thank you very much.


> 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 attribute (for 
> encapsulation). Thank you very much.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to