public Collection<TypeLiteral<?>> getMemberInjectRequests() {
return Collections.unmodifiableCollection(implementations);
}
private void matchMethods(Key<?> factoryKey) throws ErrorsException {
Errors errors = new Errors();
dependencies.add(new Dependency(Dependency.GINJECTOR, factoryKey, getContext()));
Class<?> factoryRawType = factoryType.getRawType();
// getMethods() includes inherited methods from super-interfaces.
for (Method method : factoryRawType.getMethods()) {
Key<?> returnType = getKey(factoryType.getReturnType(method), method,
method.getAnnotations(), errors);
// Get parameters with annotations.
List<TypeLiteral<?>> params = factoryType.getParameterTypes(method);
Annotation[][] paramAnnotations = method.getParameterAnnotations();
int p = 0;
List<Key<?>> paramList = new ArrayList<Key<?>>();
for (TypeLiteral<?> param : params) {
Key<?> paramKey = getKey(param, method, paramAnnotations[p++], errors);
paramList.add(assistKey(method, paramKey, errors));
}
// Try to match up the method to the constructor.
TypeLiteral<?> implementation = collector.get(returnType);
if (implementation == null) {
implementation = returnType.getTypeLiteral();
}
Constructor<?> constructor =
findMatchingConstructor(method, implementation, paramList, errors);
if (constructor == null) {
continue; // Errors are collected and thrown below.
}
// Calculate a map from method to constructor parameters and required
// keys.
String[] parameterNames = extractConstructorParameters(factoryKey,
implementation, constructor, paramList, errors, dependencies);
TypeLiteral<?> methodDeclaringType = factoryType.getSupertype(method.getDeclaringClass());
assistData.add(new AssistData(implementation, MethodLiteral.get(constructor, implementation),
MethodLiteral.get(method, methodDeclaringType), parameterNames));
implementations.add(implementation);
dependencies.addAll(guiceUtil.getMemberInjectionDependencies(factoryKey, implementation));
}
errors.throwConfigurationExceptionIfErrorsExist();
}