static <T> T getInstance(Annotation annotation, Class<T> expectedType,
                             DependencyInjector dependencyInjector) {
        @SuppressWarnings("unchecked")
        final Class<? extends T> type = (Class<? extends T>) invokeValueMethod(annotation);
        final T instance = dependencyInjector.getInstance(type);
        if (instance != null) {
            if (!expectedType.isInstance(instance)) {
                throw new IllegalArgumentException(
                        "A class specified in @" + annotation.annotationType().getSimpleName() +
                        " annotation cannot be cast to " + expectedType);
            }
            return instance;
        }

        throw new IllegalArgumentException("cannot inject the dependency for " + type.getName() +
                                           ". Use " + DependencyInjector.class.getName() +
                                           " or add a default constructor to create the instance.");
    }
Returns an instance of the specified {@link Class} which is specified in the given
{@link Annotation}.
core/src/main/java/com/linecorp/armeria/internal/server/annotation/AnnotatedObjectFactory.java