java.lang.Object
net.serenitybdd.junit5.utils.ClassUtil

public class ClassUtil extends Object
  • Field Details

  • Constructor Details

    • ClassUtil

      public ClassUtil()
  • Method Details

    • forName

      public static Class<?> forName(String name, ClassLoader classLoader) throws ClassNotFoundException, LinkageError
      Throws:
      ClassNotFoundException
      LinkageError
    • resolvePrimitiveClassName

      public static Class<?> resolvePrimitiveClassName(String name)
    • getDefaultClassLoader

      public static ClassLoader getDefaultClassLoader()
    • getAllDeclaredMethods

      public static Stream<Method> getAllDeclaredMethods(Class<?> clazz)
      Get all methods declared in the given class and all its superclasses. This walks up the class hierarchy to find methods that may be declared in parent classes.
      Parameters:
      clazz - the class to inspect
      Returns:
      a stream of all methods in the class hierarchy
    • findMethodInHierarchy

      public static Optional<Method> findMethodInHierarchy(Class<?> clazz, String methodName)
      Find a method by name in the given class or any of its superclasses. This is useful when getDeclaredMethod fails because the method is defined in a parent class.
      Parameters:
      clazz - the class to start searching from
      methodName - the name of the method to find
      Returns:
      an Optional containing the method if found
    • findMethodInHierarchy

      public static Optional<Method> findMethodInHierarchy(Class<?> clazz, String methodName, Class<?>... parameterTypes)
      Find a method by name and parameter types in the given class or any of its superclasses.
      Parameters:
      clazz - the class to start searching from
      methodName - the name of the method to find
      parameterTypes - the parameter types of the method
      Returns:
      an Optional containing the method if found