Hey Soheil,

Isn't is possible to stick to the CloudStack standards and use the 
SerializedName annotation? 
http://google-gson.googlecode.com/svn/tags/1.2.3/docs/javadocs/com/google/gson/annotations/SerializedName.html

Another option is to set a policy on gson that will automagically translate the 
java name into the underscore standard upon serialization. So isBoolean would 
become is_boolean. Look at the NiciraNvpApi, the gson policy is activated in 
the constructor.

Cheers,

Hugo

Sent from my iPhone

> On 18 mrt. 2014, at 20:34, Soheil Eizadi <seiz...@infoblox.com> wrote:
> 
> Here is a proposed solution to evaluate, use the maven-checkstyle-plugin 
> exclude feature to make exception for modules that have code convention to 
> conform to external structures. Here is sample for my use case:
> 
>        <artifactId>maven-checkstyle-plugin</artifactId>
>             <configuration>
>                  <excludes> **/infoblox/InfobloxNetworkView.java </excludes>
>             </configuration>
> 
> -Soheil
> ________________________________________
> From: Soheil Eizadi [seiz...@infoblox.com]
> Sent: Tuesday, March 18, 2014 6:26 AM
> To: dev@cloudstack.apache.org
> Subject: RE: Java Coding Convention Errors
> 
> Here is a code fragment for serialization:
> 
>            result = (T)gson.fromJson(resultString, 
> TypeToken.get(newObject.getClass()).getType());
> 
> It is just generic/single handler for all generic type corresponding to the 
> same raw type.
> 
> -Soheil
> 
> ________________________________________
> From: Hugo Trippaers [trip...@gmail.com]
> Sent: Monday, March 17, 2014 11:30 PM
> To: dev@cloudstack.apache.org
> Subject: Re: Java Coding Convention Errors
> 
> Soheil,
> 
> How are these classes serialized? There are different ways to solve this like 
> annotations with the serialized name or a gson policy.
> 
> Cheers,
> Hugo
> 
> Sent from my iPhone
> 
>> On 18 mrt. 2014, at 03:33, Soheil Eizadi <seiz...@infoblox.com> wrote:
>> 
>> Looks like in the new trunk we have turned on checks to enforce coding 
>> conventions in Eclipse? I have errors with some classes that I need to turn 
>> off:
>> "Name 'is_default' must match pattern '^_?[a-zA-Z0-9]*$'."
>> 
>> For example a declaration:
>> 
>>   private boolean is_default;
>> 
>> These classes are part of the interface for REST communication so the 
>> strings must match the corresponding JSON objects. What is the best practice 
>> to turn this off in the project for a particular Class?
>> -Soheil

Reply via email to