I mean java8 Streams 
(https://docs.oracle.com/javase/8/docs/api/java/util/stream/package-summary.html).
 
And I said that is the same as Immutable+FluentIterable because you can use 
Stream.of(values[]). And IMO this makes more sense in a DTO than using the 
interfaces on the collection frameworks (list, set, map, and worst with 
specific types like ArrayList, EnumSet, etc), because whats means a set in 
a DTO (I mean in the JSON), or worst an EnumSet? this information is not 
related to the schema of the transferred data, and I think that this makes 
the encoding/decoding much more complex. And with Streams you can get back 
to the java collection whenever you really need it quite easy, for example 
if you have 'String[] types' an array of enum names of TypeEnum, you can 
get the Set using Stream.of(types).map(TypeEnum::valueOf).colllect(toSet());

On Friday, August 19, 2016 at 8:04:37 PM UTC+2, Vassilis Virvilis wrote:
>
> Thanks for the write up. I would definitely have it in mind.
>
> BTW can you expand a bit on the stream thingy? Is there a link somewhere 
> to read about?
>
>     Vassilis
>
> On Fri, Aug 19, 2016 at 8:59 PM, Ignacio Baca Moreno-Torres <
> [email protected] <javascript:>> wrote:
>
>> Migrating everything is not a good idea, but you should give a try to 
>> arrays in new models or some parts of your application. We found that we 
>> frequently end up using Immutable collections and FluentIterable, and this 
>> is almost the same that using arrays and streams. As you said, migrating a 
>> whole project is too complicated, but you can just start using and 
>> progressively applying to the whole API if this actually works for you. In 
>> 3 years we past from using RequestFactory, to RestyGWT to almost plain 
>> request + jsinterop (actually autorest-gwt). Maybe using plain objects and 
>> arrays doesn't fit in your project, but you really should try.
>>
>> Emm... and a bit of context; I'm try to justify that the complexity added 
>> during parsing/encoding to support collections and generics really do not 
>> worth (depends on projects) if your API use DTOs and you have streams 
>> available. In our project the DTOs classes end up as a scheme definition, 
>> defining the name and type of each property and with a minimal overhead 
>> during parsing/encoding in JRE, GWT and even Android (
>> https://github.com/ibaca/autorest-nominatim-example/).
>>
>> On Friday, August 19, 2016 at 4:10:30 PM UTC+2, Vassilis Virvilis wrote:
>>>
>>> This makes sense for newer projects maybe.
>>>
>>> I already have a codebase and making trampolines to convert collections 
>>> and maps to arrays and don't know what is a terrifying option.
>>>
>>> I prefer to depend on gwt-jackson (which doesn't work for me - resty-gwt 
>>> works - resty-gwt is switching to gwt-jackson - eventually gwt-jackson will 
>>> work for me) especially if I am using jackson already in the server,
>>>
>>>
>>> On Fri, Aug 19, 2016 at 5:02 PM, Ignacio Baca Moreno-Torres <
>>> [email protected]> wrote:
>>>
>>>> IMHO supporting the whole collection frameworks is just an unnecessary 
>>>> complication. Just use plain array, not generics need, and now that stream 
>>>> are supported in GWT you has no excuse to use arrays. The inheritance is 
>>>> not solved in JsInterop for now, just try to avoid.
>>>>
>>>> On Friday, August 19, 2016 at 3:38:28 PM UTC+2, Vassilis Virvilis wrote:
>>>>>
>>>>> How about transmitting nested Collections, Map, complex inheritance 
>>>>> and generics?
>>>>>
>>>>> On Fri, Aug 19, 2016 at 4:30 PM, zakaria amine <[email protected]> 
>>>>> wrote:
>>>>>
>>>>>> I also tried to convert back to the original object: 
>>>>>>
>>>>>> @JsType(isNative=true, namespace=GLOBAL)
>>>>>> public class JSON {
>>>>>> public native static String stringify(Object obj);
>>>>>> public native static Object parse(String obj);
>>>>>>
>>>>>> }
>>>>>>
>>>>>> and then: 
>>>>>> //....
>>>>>>
>>>>>>   Record converted = (Record) JSON.parse(json);
>>>>>>
>>>>>> and it works just fine. why would we need something like gwt-jackson 
>>>>>> anymore? 
>>>>>>
>>>>>>
>>>>>> Le vendredi 19 août 2016 12:05:32 UTC+2, zakaria amine a écrit :
>>>>>>>
>>>>>>> It works. I prefer your solution.
>>>>>>>
>>>>>>> Le vendredi 19 août 2016 11:51:35 UTC+2, Jens a écrit :
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> Am Freitag, 19. August 2016 11:43:12 UTC+2 schrieb zakaria amine:
>>>>>>>>>
>>>>>>>>> I have tried something like: 
>>>>>>>>>
>>>>>>>>> @JsType(namespace=GLOBAL)
>>>>>>>>> public class Record {
>>>>>>>>> String id;
>>>>>>>>> String date;
>>>>>>>>> String data;
>>>>>>>>> public Record() {
>>>>>>>>> }
>>>>>>>>> }
>>>>>>>>>
>>>>>>>>
>>>>>>>> By default @JsType property "isNative" is false, so your Record 
>>>>>>>> class is a non-native class that might get exported to JS if you use 
>>>>>>>> -generateJsInteropExports during compilation. If you don't use that 
>>>>>>>> flag 
>>>>>>>> the @JsType is treated as a normal class I guess.
>>>>>>>>
>>>>>>>> You should use @JsType(isNative=true, namespace=GLOBAL, 
>>>>>>>> name="Object") so that your Record class becomes a plain JavaScript 
>>>>>>>> object
>>>>>>>>
>>>>>>>> -- J.
>>>>>>>>
>>>>>>> -- 
>>>>>> You received this message because you are subscribed to the Google 
>>>>>> Groups "GWT Users" group.
>>>>>> To unsubscribe from this group and stop receiving emails from it, 
>>>>>> send an email to [email protected].
>>>>>> To post to this group, send email to [email protected].
>>>>>> Visit this group at 
>>>>>> https://groups.google.com/group/google-web-toolkit.
>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> -- 
>>>>> Vassilis Virvilis
>>>>>
>>>> -- 
>>>> You received this message because you are subscribed to the Google 
>>>> Groups "GWT Users" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send 
>>>> an email to [email protected].
>>>> To post to this group, send email to [email protected].
>>>> Visit this group at https://groups.google.com/group/google-web-toolkit.
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>>
>>>
>>>
>>> -- 
>>> Vassilis Virvilis
>>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "GWT Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> To post to this group, send email to [email protected] 
>> <javascript:>.
>> Visit this group at https://groups.google.com/group/google-web-toolkit.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> -- 
> Vassilis Virvilis
>

-- 
You received this message because you are subscribed to the Google Groups "GWT 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

Reply via email to