Package rife.tools

Class ObjectUtils

java.lang.Object
rife.tools.ObjectUtils

public final class ObjectUtils extends Object
General purpose class containing common Object manipulation methods.
Since:
1.0
  • Method Details

    • genericClone

      public static <T> T genericClone(T object)
      Clone an Object if possible.

      This method returns an Object which is a clone of the input object. It checks if the method implements the Cloneable interface and then uses reflection to invoke the clone method.

      Parameters:
      object - The object to be cloned.
      Returns:
      null if the cloning failed; or

      the cloned Object instance.

    • deepClone

      public static <T> T deepClone(T object) throws CloneNotSupportedException
      Try to create a deep clone of the provides object. This handles arrays, collections and maps. If the class in not a supported standard JDK collection type the genericClone will be used instead.
      Parameters:
      object - The object to be copied.
      Throws:
      CloneNotSupportedException
    • getBaseClass

      public static Class getBaseClass(Object object)
      This routine returns the base class of an object. This is just the class of the object for non-arrays.
      Parameters:
      object - The object whose base class you want to retrieve.