java.lang.Object
net.serenitybdd.junit5.utils.ClassUtil
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfindMethodInHierarchy(Class<?> clazz, String methodName) Find a method by name in the given class or any of its superclasses.findMethodInHierarchy(Class<?> clazz, String methodName, Class<?>... parameterTypes) Find a method by name and parameter types in the given class or any of its superclasses.static Class<?>forName(String name, ClassLoader classLoader) getAllDeclaredMethods(Class<?> clazz) Get all methods declared in the given class and all its superclasses.static ClassLoaderstatic Class<?>
-
Field Details
-
ARRAY_SUFFIX
Suffix for array class names:"[]".- See Also:
-
CGLIB_CLASS_SEPARATOR
The CGLIB class separator:"$$".- See Also:
-
CLASS_FILE_SUFFIX
The ".class" file suffix.- See Also:
-
-
Constructor Details
-
ClassUtil
public ClassUtil()
-
-
Method Details
-
forName
public static Class<?> forName(String name, ClassLoader classLoader) throws ClassNotFoundException, LinkageError - Throws:
ClassNotFoundExceptionLinkageError
-
resolvePrimitiveClassName
-
getDefaultClassLoader
-
getAllDeclaredMethods
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
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 frommethodName- 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 frommethodName- the name of the method to findparameterTypes- the parameter types of the method- Returns:
- an Optional containing the method if found
-