Package sonia.scm.io

Class DeepCopy

java.lang.Object
sonia.scm.io.DeepCopy

public final class DeepCopy extends Object
Utility for making deep copies (vs. clone()'s shallow copies) of objects. Objects are first serialized and then deserialized. Error checking is fairly minimal in this implementation. If an object is encountered that cannot be serialized (or that references an object that cannot be serialized) an error is printed to System.err and null is returned. Depending on your specific application, it might make more sense to have copy(...) re-throw the exception.
Since:
1.29
See Also:
  • Method Details

    • copy

      public static <T> T copy(T orig) throws IOException
      Returns a copy of the object, or null if the object cannot be serialized.
      Type Parameters:
      T - type of object to copy
      Parameters:
      orig - object to copy
      Returns:
      deep copy of object
      Throws:
      IOException