/**
* Traverses through the dependencies of the providers in order to get to the user's binding.
*/
private Binding<?> getBindingFromMapProvider(Injector injector, Provider<T> mapProvider) {
HasDependencies deps = (HasDependencies) mapProvider;
Key<?> depKey = Iterables.getOnlyElement(deps.getDependencies()).getKey();
// The dep flow is (and will stay this way, until we change the internals) --
// Key[type=Provider<java.lang.String>, annotation=@Element(type=MAPBINDER)]
// -> Key[type=String, annotation=@Element(type=MAPBINDER)]
// -> Key[type=Provider<String>, annotation=@Element(type=OPTIONALBINDER)]
// -> Key[type=String, annotation=@Element(type=OPTIONALBINDER)]
// The last one points to the user's binding.
for (int i = 0; i < 3; i++) {
deps = (HasDependencies) injector.getBinding(depKey);
depKey = Iterables.getOnlyElement(deps.getDependencies()).getKey();
}
return injector.getBinding(depKey);
}