code: public static <T> Method getFunctionInterfaceMethod(Class<?> clz) {
      if (!clz.isInterface()) {
        return null;
      }
      Method[] ms = Stream.of(clz.getMethods())
          .filter(m -> !(m.isDefault() || m.isBridge() || m.isSynthetic() || Modifier.isStatic(m.getModifiers())))
          .toArray(Method[]::new);
      if (ms.length != 1) {
        return null;
      }
      return ms[0];
    }
docs: Get the method from a function interface
  
  @param clz
  @return null if the given class is not a function interface