I have a map<string, InnerClass>
, where the inner apex class containing no sObjects, just a bunch of simple variable types like booleans, integers and strings. (It also contains another inner class which also has only simple variable types, but I assume that doesn't matter).
My goal is to clone this map several times, putting different values in the WrapperClass properties for each map. I'm currently using the map clone()
method.
Problem appears to be that when I'm updating the values on my latest clone, all the previously cloned maps update their values the same way. In other words, it appears that the clone()
method only passed a reference to the existing WrapperClass object, rather than cloning it.
I know deepclone()
would solve this problem, but it is only designed for sObjects. How can I clone my map in such a way that new copies of my inner classes are created for each map?