Class DeepCloner

java.lang.Object
org.powermock.classloading.DeepCloner
All Implemented Interfaces:
DeepClonerSPI

public class DeepCloner extends 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.

  • Constructor Details

    • DeepCloner

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

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

    • 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.
    • clone

      public <T> T clone(T objectToClone, boolean includeStandardJavaType)
      Parameters:
      objectToClone - the object to clone
      includeStandardJavaType - true also clones standard java types (using simple serialization), false simply reference to these objects (will be same instance).
      Returns:
      A deep clone of the object to clone.