akshayyn / cloning

Automatically exported from code.google.com/p/cloning
Other
0 stars 0 forks source link

Can you please tell me how to soft-clone (i.e. set references) or NULL for a Set in my class #18

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I have a Entity class A.java
it has some fields and some Set<otherEntity> of OtherEntity.java

Now I want to clone A.java but don't want the Set to be cloned, i.e. it should 
only refer the same set as that of source Entity A.java, similar to what 
happens when I used dontClone() method for some class and that Class (if 
encountered) in the source Entity then it is referenced with the same object 
instead of cloning.
Scenario:
Class A {
field f1;
field f2;
Set<B> bSet;
}
Class B {
field b1;
field b2;
}
Now I want to clone A
Expected:
A new Object (say C) with all the fields cloned from A.
but bSet of C should share the reference with bSet of A.

Looking forward for a quick response.
Thanks in advance.

Original issue reported on code.google.com by vinaysha...@gmail.com on 17 Apr 2013 at 6:00

GoogleCodeExporter commented 8 years ago
Hi, this can't be done with the current version as it doesn't support selective 
cloning of fields. I am modifying this to a request for enhancement

Original comment by kostas.k...@googlemail.com on 18 Apr 2013 at 5:39