code: private Method findFromString(Class<?> cls) {
          // find in declared methods
          Method[] methods = cls.getDeclaredMethods();
          Method matched = null;
          for (Method method : methods) {
              if (!method.isBridge() && !method.isSynthetic()) {
                  FromString fromString = method.getAnnotation(FromString.class);
                  if (fromString != null) {
                      if (matched != null) {
                          throw new IllegalStateException("Two methods are annotated with @FromString: " + cls.getName());
                      }
                      matched = method;
                  }
              }
          }
          // check for factory
          FromStringFactory factory = cls.getAnnotation(FromStringFactory.class);
          if (factory != null) {
              if (matched != null) {
                  throw new IllegalStateException("Class annotated with @FromString and @FromStringFactory: " + cls.getName());
              }
              Method[] factoryMethods = factory.factory().getDeclaredMethods();
              for (Method method : factoryMethods) {
                  if (!method.isBridge() && !method.isSynthetic()) {
                      // handle factory containing multiple FromString for different types
                      if (cls.isAssignableFrom(method.getReturnType())) {
                          FromString fromString = method.getAnnotation(FromString.class);
                          if (fromString != null) {
                              if (matched != null) {
                                  throw new IllegalStateException("Two methods are annotated with @FromString on the factory: " + factory.factory().getName());
                              }
                              matched = method;
                          }
                      }
                  }
              }
          }
          return matched;
      }
docs: Finds the conversion method.
  
  @param cls  the class to find a method for, not null
  @param matched  the matched method, may be null
  @return the method to call, null means not found
  @throws RuntimeException if invalid