Class DeepCopy


  • public class DeepCopy
    extends java.lang.Object
    from http://javatechniques.com/blog/faster-deep-copies-of-java-objects/, see also https://stackoverflow.com/a/64066 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.
    • Constructor Summary

      Constructors 
      Constructor Description
      DeepCopy()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.Object copy​(java.lang.Object orig)
      Returns a copy of the object, or null if the object cannot be serialized.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DeepCopy

        public DeepCopy()
    • Method Detail

      • copy

        public static java.lang.Object copy​(java.lang.Object orig)
        Returns a copy of the object, or null if the object cannot be serialized.