| Issue 76: | Add conversion from a "framework" to another (from exemple: Guava to RxJava) ? | |
| 1 person starred this issue and may be notified of changes. | Back to list |
> What steps will reproduce the problem? It's an enhancement. > What is the expected output? What do you see instead? If on a project I use Guava & RxJava. I have to define something like that : ---------------------------------- // For Guava. public final static Personne Personne_G = FuncitoGuava.callsTo(Personne.class); public final static Function<Personne, Integer> getAge_g = FuncitoGuava.functionFor(Personne_G.getAge()); ... // For RxJava. public final static Personne Personne_R = FuncitoRxJava.callsTo(Personne.class); public final static Func1<Personne, Integer> getAge_r = FuncitoRxJava.func1For(Personne_R.getAge()); ... ----------------------------------- It could be great to have something like "conversion" method(s) : // RxJava Func1 "computed" from the Guava Function. public final static Func1<Personne, Integer> getAge_r = FuncitoRxJava.from(getAge_g); Regards, Ronan.
Nov 1, 2013
Project Member
#1
kandpwel...@gmail.com
Labels:
-Type-Defect Type-Enhancement
Nov 2, 2013
Sharing the same Proxy (ie PERSONNE) between several use is very good. The advantage of conversion, is just to **be sure to stay synchronised** between multiple framework use. Exemple : Qux getQux_g = guava().functionFor(PERSONNE.getFoo().getTheGoodBar().getBaz().getQux()); ... Qux getQux_r = rxJava().functionFor(PERSONNE.getFoo().getOldBar().getBaz().getQux(); Here imagine the developper changed the guava version but forgot to change the rxJava version.
Nov 2, 2013
(deleted my comment from a moment ago and reposting with spelling correction): OK, I understand the theoretical usefulness now. But is this something you would immediately find useful on a regular basis, and do you think many others would? I am very happy to consider adding this, but I always need to make sure that any new feature does not amount to "clutter" that would get very little use in the community of users. Some technical notes: all of the factory methods actually return subclasses of the 3rd party classes. For example instead of making a "pure" RxJava class Func1, it actually returns a Funcito subclass called RxJavaFunc1. This is true for all supported 3rd party functor classes. This would theoretically make it easy to do what you ask. Except all of my factory method signatures still refer to only the "pure" 3rd party functor classes. So the user would be required to perform a cast to be able to provide the functionality you request. Not terrible, but less beautiful than what I would hope for public API.
Nov 2, 2013
(continuing from previous post) So actual usage - per you example -- would probably look more like this (fully qualified generics required in the typecast below): public final static Func1<Personne, Integer> getAge_r = FuncitoRxJava.func1From((GuavaFunction<Personne,Integer>)getAge_g); ... a little ugly IMHO, but it is do-able and would accomplish what you want: synchronized functors across multiple 3rd party APIs. |