Class SerializableCloner

java.lang.Object
com.comphenix.protocol.reflect.cloning.SerializableCloner
All Implemented Interfaces:
Cloner

public class SerializableCloner extends Object implements Cloner
Represents a cloner that can clone any class that implements Serializable.
  • Constructor Details

    • SerializableCloner

      public SerializableCloner()
  • Method Details

    • canClone

      public boolean canClone(Object source)
      Description copied from interface: Cloner
      Determine whether the current cloner can clone the given object.
      Specified by:
      canClone in interface Cloner
      Parameters:
      source - - the object that is being considered.
      Returns:
      TRUE if this cloner can actually clone the given object, FALSE otherwise.
    • clone

      public Object clone(Object source)
      Description copied from interface: Cloner
      Perform the clone.

      This method should never be called unless a corresponding Cloner.canClone(Object) returns TRUE.

      Specified by:
      clone in interface Cloner
      Parameters:
      source - - the value to clone.
      Returns:
      A cloned value.
    • clone

      public static <T extends Serializable> T clone(T obj)
      Clone the given object using serialization.
      Type Parameters:
      T - Type
      Parameters:
      obj - - the object to clone.
      Returns:
      The cloned object.
      Throws:
      RuntimeException - If we were unable to clone the object.