@SuppressWarnings("unchecked")
    @Nullable
    static <T> Function<String, T> getCreatorMethod(Class<T> clazz) {
        final MethodHandle methodHandle = Stream.of("of", "valueOf", "fromString")
                     .map((methodName) -> getPublicStaticMethodHandle(clazz, methodName))
                     .filter(Objects::nonNull)
                     .findFirst()
                     .orElseGet(() -> getStringConstructorMethodHandle(clazz));
        if (methodHandle == null) {
            return null;
        }
        return str -> {
            try {
                return (T) methodHandle.invokeWithArguments(str);
            } catch (InvocationTargetException e) {
                final Throwable cause = e.getCause();
                assert cause != null;
                return Exceptions.throwUnsafely(cause);
            } catch (Throwable t) {
                return Exceptions.throwUnsafely(t);
            }
        };
    }
Try to get a function that can create an instance of type {@code clazz} with a single
{@link String} argument.
@param <T> the expected resulting type
@param clazz the class being introspected
@return a function that takes a {@link String} and produces a {@code T}
core/src/main/java/com/linecorp/armeria/internal/server/annotation/AnnotatedServiceTypeUtil.java