I have an object of type Record
which implements Serializable
. In my task, I have to split it into two objects of the same type, where one has all original fields except for one field, and the other only the field excluded at the previous step. Here is what I did:
Record firstPart = SerializationUtils.clone(record);
Record secondPart = new Record();
firstPart.setUid(null);
secondPart.setUid(record.getUid());
Now, I was told that I shouldn't have cloned record
. Perhaps they mean it's too expensive if the record is big enough. I tried to figure out how to avoid cloning, but can't get it. What could be the solution?