protected <T> T valueForMember(final String name, final Member injectionTarget,
            final Class<T> injectionType,
            final Channel channel) throws BeansException {
        if (Channel.class.equals(injectionType)) {
            return injectionType.cast(channel);
        } else if (AbstractStub.class.isAssignableFrom(injectionType)) {

            @SuppressWarnings("unchecked") // Eclipse incorrectly marks this as not required
            AbstractStub<?> stub = createStub(
                    (Class<? extends AbstractStub<?>>) injectionType.asSubclass(AbstractStub.class), channel);
            for (final StubTransformer stubTransformer : getStubTransformers()) {
                stub = stubTransformer.transform(name, stub);
            }
            return injectionType.cast(stub);
        } else {
            if (injectionTarget != null) {
                throw new InvalidPropertyException(injectionTarget.getDeclaringClass(), injectionTarget.getName(),
                        "Unsupported type " + injectionType.getName());
            } else {
                throw new BeanInstantiationException(injectionType, "Unsupported grpc stub or channel type");
            }
        }
    }
Creates the instance to be injected for the given member.

@param <T> The type of the instance to be injected.
@param name The name that was used to create the channel.
@param injectionTarget The target member for the injection.
@param injectionType The class that should injected.
@param channel The channel that should be used to create the instance.
@return The value that matches the type of the given field.
@throws BeansException If the value of the field could not be created or the type of the field is unsupported.
grpc-client-spring-boot-starter/src/main/java/net/devh/boot/grpc/client/inject/GrpcClientBeanPostProcessor.java