private Injectee parameterToInjectee(Constructor<T> constructor, Parameter parameter, int position) { InjecteeImpl injectee = new InjecteeImpl(); injectee.setParent(constructor); if (parameter.getParameterizedType() instanceof ParameterizedType && InjectionUtils.isProvider(parameter.getParameterizedType())) { ParameterizedType paramType = (ParameterizedType) parameter.getParameterizedType(); injectee.setRequiredType(paramType.getActualTypeArguments()[0]); injectee.setProvider(true); } else { injectee.setRequiredType(parameter.getType()); } injectee.setPosition(position); return injectee; }
/** * Returns the injectee for a field. * * @param bean bean in which the field is placed. * @param field the field to analyze. * @return the list (in order) of parameters to the constructor. */ private static Injectee getFieldInjectee(Bean<?> bean, Field field) { Set<Annotation> annotations = Arrays.stream(field.getAnnotations()) .collect(ImmutableCollectors.toImmutableSet()); Type adjustedType = ReflectionUtils.resolveField(bean.getBeanClass(), field); InjecteeImpl injectee = new InjecteeImpl(); injectee.setParentClassScope(bean.getScope()); if (isProvider(adjustedType)) { ParameterizedType paramType = (ParameterizedType) adjustedType; injectee.setRequiredType(paramType.getActualTypeArguments()[0]); injectee.setProvider(true); } else { injectee.setRequiredType(adjustedType); } injectee.setParent(field); injectee.setRequiredQualifiers(getFieldAdjustedQualifierAnnotations(field, annotations)); return injectee; }