Class CloneChecker<C>

java.lang.Object
caseine.reflect.CloneChecker<C>
Type Parameters:
C - The class to check

public class CloneChecker<C> extends Object
Assists in checking the correct writing of the clone method of a class C by knowing if

  • C implements or not Cloneable
  • clone is not declared or well declared
  • clone returns C
  • clone does not throw CloneNotSupportedException
  • clone does not use new
Also allows you to retrieve parsed elements.
  • Constructor Details

    • CloneChecker

      @Deprecated public CloneChecker(Class<C> classToCheck, com.github.javaparser.ast.stmt.BlockStmt bodyToCheck)
      Deprecated.
    • CloneChecker

      public CloneChecker(Class<C> classToCheck)
      Parameters:
      classToCheck - The object class of class C whose clone method we want to check
  • Method Details

    • getCheckedClass

      public Class<C> getCheckedClass()
      Returns:
      Object class of C
    • getBodyToCheck

      public com.github.javaparser.ast.stmt.BlockStmt getBodyToCheck()
      Returns:
      The parsed body of the clone method of C is it exists or null
    • isCloneDeclared

      public boolean isCloneDeclared()
      Returns:
      The clone method is declared in the class C
    • isInterfaceCloneableImplemented

      public boolean isInterfaceCloneableImplemented()
      Returns:
      C implements Cloneable
    • isReturnsC

      public boolean isReturnsC()
      Returns:
      clone exists and returns an objet of class C
    • isNotThrowCloneNotSupportedException

      public boolean isNotThrowCloneNotSupportedException()
      Returns:
      clone exists and does not throw CloneNotSupportedException
    • isNotUseNew

      public boolean isNotUseNew()
      Returns:
      clone exists and does not throw CloneNotSupportedException
    • getClone

      public Method getClone()
      Returns:
      the reflected object class of the clone method or null if does not exist