public class StackUtils
extends java.lang.Object
Set of static methods to be used when parsing of the current Thread stacktrace, allowing to retrieve helpful information about the classes and methods actually calling the Approval Tests.
Those methods allow to retrieve information to be used for generating the default names of files and folders to be used by the Approval Files.
| Constructor and Description |
|---|
StackUtils() |
| Modifier and Type | Method and Description |
|---|---|
static java.lang.Class<?> |
callerClass(java.lang.Class<?>... referenceClass)
Returns the caller class of
reference by searching the current thread stacktrace. |
static java.util.Optional<java.lang.String> |
callerMethod(java.lang.Class<?> referenceClass)
Returns the caller method of the provided
referenceClass. |
public static java.lang.Class<?> callerClass(java.lang.Class<?>... referenceClass)
Returns the caller class of reference by searching the current thread stacktrace.
We consider the caller class to be the first one found in the current thread stacktrace after finding the reference one.
referenceClass - A non-null class for which we want to find the caller classpublic static java.util.Optional<java.lang.String> callerMethod(java.lang.Class<?> referenceClass)
Returns the caller method of the provided referenceClass.
We consider the caller method to be the first method from the referenceClass called in the current thread stacktrace, which isn’t a lambda.
If found in the current thread stacktrace, the method name will be returned, wrapped in an Optional. If no method can be found, an empty Optional will be returned.
referenceClass - The referenceClass for which we want to search the caller method in the current thread stacktraceOptional object containing either the caller method name (as a String) or an empty value if it cannot be foundCopyright © 2018 Write Them First!. All rights reserved.