public static Optional<Method> safeMethodLookup(Class<?> klass, String methodName, Class<?>... parameterTypes) {
        try {
            return Optional.of(klass.getMethod(methodName, parameterTypes));
        } catch (ReflectiveOperationException | SecurityException ignored) {
            try {
                return Optional.of(klass.getDeclaredMethod(methodName, parameterTypes));
            } catch (ReflectiveOperationException | SecurityException ignored2) {
                return Optional.empty();
            }
        }
    }
Lookup a specific method name related to a class. This helper tries {@link Class#getMethod(String, Class[])} first, then
falls back to {@link Class#getDeclaredMethod(String, Class[])}.

@param klass          A class
@param methodName     A method name
@param parameterTypes All parameter types for the method
@return A {@link Method} object wrapped in an {@link Optional} if the method could be found, {@link Optional#empty()} otherwise
core/src/main/java/org/jdbi/v3/core/internal/JdbiClassUtils.java