Sorry for reviving this thread. I do have a recurring need for 
duplicating/cloning (shallow and deep) objects, so I would be interested in 
a (elegant) solution (for both).

1. (not very elegant) I have tried to do serialize/deserialize using my rpc 
TypeOracle etc... but I have the effect mentioned by Thomas.

2. if we could, via an annotation automatically generate a constructor 
(kind of like in lombok) taking an object and duplicating the field, eg

public T(T original, boolean shallow) {
  field1 = original.field1;
  // etc... + recursively copy if !shallow && is an object that has the 
said annotation
}

we could also add an annotation to filter the fields that should not be 
copied, the fields that shoudl never be deep copied, etc...

1 would have the advantage of not generating any extra code for each class 
but is quite resource intensive + does not allow for deep/shallow copies

2 would do it for me, unless there is a glitch that I missed somewhere.

With auto beans I need to write down an interface, etc... which defeats the 
point for me. I just want to be able to duplicate objects without having to 
maintain an interface.

Any thoughts/comments are very welcome ;-)




On Wednesday, 7 December 2011 11:34:46 UTC+1, Thomas Broyer wrote:
>
> Just an additional note to what others said: GWT-RPC serialization is 
> asymmetric, to have the best (but still rather poor) performance on the 
> client; so you cannot use 
> SerializationStreamReader/SerializationStreamWriter to clone an object by 
> roundtripping on the client-side.

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" 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 http://groups.google.com/group/google-web-toolkit?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to