This collapses requests for synthetic bindings so that a request for a multibound key
* points to all of the contributions for the multibound object. It does so by recursively calling
* this method, with each dependency's key as the {@code targetKey}.
*/
private void addEdgesForDependencyRequest(
DependencyRequest dependency, BindingNode bindingNode, BindingGraph graph) {
if (!dependency.requestElement().isPresent()) {
return;
}
Binding binding = bindingNode.delegate();
if (binding.bindingElement().isPresent()) {
addDependencyEdge(dependency, binding);
} else {
for (Edge outEdge : graph.network().outEdges(bindingNode)) {
if (outEdge instanceof DependencyEdge) {
Node outNode = graph.network().incidentNodes(outEdge).target();
addEdgesForDependencyRequest(dependency, (BindingNode) outNode, graph);
}
}
}
for (BindingDeclaration bindingDeclaration :
Iterables.concat(
bindingNode.multibindingDeclarations(),
bindingNode.optionalBindingDeclarations())) {
addDependencyEdge(dependency, bindingDeclaration);
}
}
private void addDependencyEdge(
DependencyRequest dependency, BindingDeclaration bindingDeclaration) {
Element requestElement = dependency.requestElement().get();
Element bindingElement = bindingDeclaration.bindingElement().get();
Optional