@Override
    public Class<?> componentType() {
        if (Provider.class.isAssignableFrom(clazz)) {
            //TODO: Test what happens if you ask for something that isn't a class, e.g. a parameterized type.

            List<Type> allGenericInterfaces = allSuperClasses(clazz).stream().flatMap(c -> Arrays.stream(c.getGenericInterfaces())).toList();
            for (Type t : allGenericInterfaces) {
                if (t instanceof ParameterizedType && ((ParameterizedType) t).getRawType().equals(Provider.class)) {
                    Type[] typeArgs = ((ParameterizedType) t).getActualTypeArguments();
                    if (typeArgs != null && typeArgs.length > 0) {
                        return (Class<?>) typeArgs[0];
                    }
                }
            }
            throw new IllegalStateException("Component type cannot be resolved");
        } else {
            return clazz;
        }
    }
@author Tony Vaagenes
@author gjoranv
@author ollivir
container-core/src/main/java/com/yahoo/container/di/componentgraph/core/ComponentNode.java