sinamdar2015 / google-gson

Automatically exported from code.google.com/p/google-gson
0 stars 0 forks source link

Include Strategy? #396

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
In the actual version of the google-gson developers are able to create a 
customized strategy to field exclusion and this is great, I was able to create 
a strategy that I think to be smarter than the original one.

My strategy doesn't just allow me to exclude fields by their name because 
sometimes the name repeats itself across a lot of classes (most common in JPA 
entities) but it also allows me to specify the class in which the field that I 
want to exclude lives. This is working great because it used to generate lots 
of circular references and I was compelled to exclude the fields that generates 
that circular references, but how that name is common across some entities I 
had seen myself in trouble using the default behavior that excludes every field 
in the object graph with that specified name.

Therefore, I think it would be great to enable this kind of feature either 
native in the GsonBuilder or by enabling customizing include strategy as today 
exists for excluding. What you guys think about this?

Thanks.

Original issue reported on code.google.com by Jayrmo...@gmail.com on 30 Dec 2011 at 12:44

GoogleCodeExporter commented 9 years ago
What could you do with an inclusion strategy that you can't do with 
ExclusionStrategy?

Original comment by limpbizkit on 11 Feb 2012 at 6:37

GoogleCodeExporter commented 9 years ago

Original comment by limpbizkit on 19 Mar 2012 at 3:30