JamesDeCarlo / google-gson

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

Allow annotations to specify type adapters #336

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
https://groups.google.com/forum/?hl=en_US#!topic/google-gson/JR-7nVdLSMA

Original issue reported on code.google.com by inder123 on 26 Jun 2011 at 5:51

GoogleCodeExporter commented 9 years ago
De-prioritizing this to low. We regret adding features like this to Guice. The 
fact that you can specify a type in the GSON instance and on the type means you 
need precedence rules; that's quite unpleasant. 

Original comment by limpbizkit on 2 Oct 2011 at 3:43

GoogleCodeExporter commented 9 years ago
Sorry, probably I am missing something here. How is this a "Guice" feature. I 
do see the possible complications that you are talking about, but I do have 
belief unpleasantness could be hidden in the implementation and not exposed to 
user through too much semantics. 
If you think I am not missing too much, then I could probably work on a 
proposal to help explain better, let me know.

Thanks !
guru

Original comment by guru...@gmail.com on 2 Oct 2011 at 5:24

GoogleCodeExporter commented 9 years ago
Guice has two ways to attach a provider to a type. In the central Injector:
 A. bind(Foo.class).to(DatabaseFoo).class;
or on the type itself:
 B. @ImplementedBy(DatabaseFoo.class)
    class Foo {...}

Approach B loses because it means sometimes configuration is in the central 
place and sometimes its on the types. So you never get a full picture of the 
application's configuration.

Original comment by limpbizkit on 2 Oct 2011 at 9:57

GoogleCodeExporter commented 9 years ago
I still don't think this is a good idea for the framework. But with Gson 2.1's 
TypeAdapterFactory type, you can do this yourself if you want in only a few 
lines of code.

Original comment by limpbizkit on 30 Dec 2011 at 6:47