"adrian(a)jboss.org" wrote :
| Why are you "cloning" fields that are direct referenes? What does it
achieve?
|
You mean immutables?
Does Object::clone do that already for me?
"adrian(a)jboss.org" wrote :
| This looks overally complicated and an obvious misuse of generics again.
| Why have generics then do all the casting and suppress warnings?
|
| The way to clone collections is something like:
|
|
| | Set<String> aliases = this.getAliases();
| | if (aliases != null)
| | clone.setAliases(new HashSet<String>(aliases));
| |
All would be fine if Object::getClass returned the right Class generic. :-)
I don't wanna do that extra 2 lines (null check and the new collection instantiation)
for every cloning of the collection.
And I guess I would also have to iterate over all the collection items that are not
immutable and clone them before adding them to new collection instance.
Another code that I don't want to duplicate.
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4142111#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...