code: private static Method[] getAllPublicMethods(Class<?> clazz) {
          if (clazz == null) {
              throw new IllegalArgumentException("You must specify a class in order to get the methods.");
          }
          Set<Method> methods = new LinkedHashSet<Method>();
  
          for (Method method : clazz.getMethods()) {
              method.setAccessible(true);
              methods.add(method);
          }
          return methods.toArray(new Method[0]);
      }
docs: Get all public methods for a class (no duplicates)! Note that the
  class-hierarchy will not be traversed.
  
  @param clazz The class whose methods to get.
  @return All public methods declared in class.