Class CloneUtil

java.lang.Object
com.webfirmframework.wffweb.clone.CloneUtil

public final class CloneUtil extends Object
A utility class for clone operations.
Since:
1.0.0
  • Method Summary

    Modifier and Type
    Method
    Description
    static <T> T
    deepClone(T objectToBeClonned)
     
    static <T> T
    deepCloneOnlyIfContains(T objectToBeClonned, List<T> objects)
    clones only if objects contains the given objectToBeClonned, otherwise returns the same object.
    static <T> T
    deepCloneOnlyIfContains(T objectToBeClonned, Set<T> objects)
    clones only if objects contains the given objectToBeClonned, otherwise returns the same object.
    static <T> T
    deepCloneOnlyIfContains(T objectToBeClonned, T[] objects)
    clones only if objects contains the given objectToBeClonned, otherwise returns the same object.
    static <T> T
    deepCloneOnlyIfDoesNotContain(T objectToBeClonned, List<T> objects)
    clones only if objects doesn't contain the given objectToBeClonned, otherwise returns the same object.
    static <T> T
    deepCloneOnlyIfDoesNotContain(T objectToBeClonned, Set<T> objects)
    clones only if objects doesn't contain the given objectToBeClonned, otherwise returns the same object.
    static <T> T
    deepCloneOnlyIfDoesNotContain(T objectToBeClonned, T[] objects)
    clones only if objects doesn't contain the given objectToBeClonned, otherwise returns the same object.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • deepCloneOnlyIfContains

      public static <T> T deepCloneOnlyIfContains(T objectToBeClonned, T[] objects) throws CloneNotSupportedException
      clones only if objects contains the given objectToBeClonned, otherwise returns the same object.
      Parameters:
      objectToBeClonned - from which a new object will be cloned. null will be returned for null value.
      objects - to check if it contains objectToBeClonned.
      Returns:
      the new cloned object only if objects contains the given objectToBeClonned, otherwise returns the same object. If objectToBeClonned is null then returns null. If objects is null then objectToBeClonned will be returned.
      Throws:
      CloneNotSupportedException
      Since:
      1.0.0
    • deepCloneOnlyIfContains

      public static <T> T deepCloneOnlyIfContains(T objectToBeClonned, List<T> objects) throws CloneNotSupportedException
      clones only if objects contains the given objectToBeClonned, otherwise returns the same object.
      Parameters:
      objectToBeClonned - from which a new object will be cloned. null will be returned for null value.
      objects - to check if it contains objectToBeClonned.
      Returns:
      the new cloned object only if objects contains the given objectToBeClonned, otherwise returns the same object. If objectToBeClonned is null then returns null. If objects is null then objectToBeClonned will be returned.
      Throws:
      CloneNotSupportedException
      Since:
      1.0.0
    • deepCloneOnlyIfContains

      public static <T> T deepCloneOnlyIfContains(T objectToBeClonned, Set<T> objects) throws CloneNotSupportedException
      clones only if objects contains the given objectToBeClonned, otherwise returns the same object.
      Parameters:
      objectToBeClonned - from which a new object will be cloned. null will be returned for null value.
      objects - to check if it contains objectToBeClonned.
      Returns:
      the new cloned object only if objects contains the given objectToBeClonned, otherwise returns the same object. If objectToBeClonned is null then returns null. If objects is null then objectToBeClonned will be returned.
      Throws:
      CloneNotSupportedException
      Since:
      1.0.0
    • deepCloneOnlyIfDoesNotContain

      public static <T> T deepCloneOnlyIfDoesNotContain(T objectToBeClonned, T[] objects) throws CloneNotSupportedException
      clones only if objects doesn't contain the given objectToBeClonned, otherwise returns the same object.
      Parameters:
      objectToBeClonned - from which a new object will be cloned. null will be returned for null value.
      objects - to check if it doesn't contain objectToBeClonned.
      Returns:
      the new cloned object only if objects doesn't contain the given objectToBeClonned, otherwise returns the same object. If objectToBeClonned is null then returns null. If objects is null then the cloned object will be returned.
      Throws:
      CloneNotSupportedException
      Since:
      1.0.0
    • deepCloneOnlyIfDoesNotContain

      public static <T> T deepCloneOnlyIfDoesNotContain(T objectToBeClonned, List<T> objects) throws CloneNotSupportedException
      clones only if objects doesn't contain the given objectToBeClonned, otherwise returns the same object.
      Parameters:
      objectToBeClonned - from which a new object will be cloned. null will be returned for null value.
      objects - to check if it doesn't contain objectToBeClonned.
      Returns:
      the new cloned object only if objects doesn't contain the given objectToBeClonned, otherwise returns the same object. If objectToBeClonned is null then returns null. If objects is null then the cloned object will be returned.
      Throws:
      CloneNotSupportedException
      Since:
      1.0.0
    • deepCloneOnlyIfDoesNotContain

      public static <T> T deepCloneOnlyIfDoesNotContain(T objectToBeClonned, Set<T> objects) throws CloneNotSupportedException
      clones only if objects doesn't contain the given objectToBeClonned, otherwise returns the same object.
      Parameters:
      objectToBeClonned - from which a new object will be cloned. null will be returned for null value.
      objects - to check if it doesn't contain objectToBeClonned.
      Returns:
      the new cloned object only if objects doesn't contain the given objectToBeClonned, otherwise returns the same object. If objectToBeClonned is null then returns null. If objects is null then the cloned object will be returned.
      Throws:
      CloneNotSupportedException
      Since:
      1.0.0
    • deepClone

      public static <T> T deepClone(T objectToBeClonned) throws CloneNotSupportedException
      Parameters:
      objectToBeClonned - from which a new object will be cloned. null will be returned for null value.
      Returns:
      the newly cloned object or null if objectToBeClonned is null.
      Throws:
      CloneNotSupportedException
      Since:
      1.0.0