Class DeepCloner

  • All Implemented Interfaces:
    DeepClonerSPI

    public class DeepCloner
    extends java.lang.Object
    implements DeepClonerSPI

    The purpose of the deep cloner is to create a deep clone of an object. An object can also be cloned to a different class-loader.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private com.thoughtworks.xstream.XStream xStream  
    • Constructor Summary

      Constructors 
      Constructor Description
      DeepCloner()
      Clone using the current ContextClassLoader.
      DeepCloner​(java.lang.ClassLoader classLoader)
      Clone using the supplied ClassLoader.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      <T> T clone​(T objectToClone)
      Clones an object.
      private void disableSecurity()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • xStream

        private final com.thoughtworks.xstream.XStream xStream
    • Constructor Detail

      • DeepCloner

        public DeepCloner​(java.lang.ClassLoader classLoader)
        Clone using the supplied ClassLoader.
        Parameters:
        classLoader - - the classloader to loaded cloned classes.
      • DeepCloner

        public DeepCloner()
        Clone using the current ContextClassLoader.
    • Method Detail

      • disableSecurity

        private void disableSecurity()
      • clone

        public <T> T clone​(T objectToClone)
        Clones an object.
        Specified by:
        clone in interface DeepClonerSPI
        Parameters:
        objectToClone - the object to clone.
        Returns:
        A deep clone of the object to clone.