private static Function<Object[], Type> getTypeGetter(final JavaMethod method) {
    if (method.getParameterCount() >= 1 && method.getParameterTypes()[0].equals(Class.class)) {
      return s -> (Type)s[0];
    }

    if (method.getParameterCount() == 2 && method.getParameterTypes()[1].equals(Class.class)) {
      return s -> (Type)s[1];
    }

    return s -> method.getGenericReturnType();
  }
private static Function<Object[], Type> getTypeGetter(final JavaMethod method)